mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
lightningd: add notleak annotations.
We have things which we don't keep a pointer to, but aren't leaks. Some are simply eternal (eg. listening sockets), others cases are io_conn tied to the lifetime of an fd, and timers which expire. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
6c951bf7e0
commit
ccb7047291
@@ -7,6 +7,7 @@
|
||||
#include <ccan/str/hex/hex.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/json.h>
|
||||
#include <common/memleak.h>
|
||||
#include <common/version.h>
|
||||
#include <common/wireaddr.h>
|
||||
#include <errno.h>
|
||||
@@ -633,7 +634,9 @@ static struct io_plan *incoming_jcon_connected(struct io_conn *conn,
|
||||
struct lightningd *ld)
|
||||
{
|
||||
log_info(ld->log, "Connected json input");
|
||||
return jcon_connected(conn, ld);
|
||||
|
||||
/* Lifetime of JSON conn is limited to fd connect time. */
|
||||
return jcon_connected(notleak(conn), ld);
|
||||
}
|
||||
|
||||
void setup_jsonrpc(struct lightningd *ld, const char *rpc_filename)
|
||||
@@ -648,7 +651,8 @@ void setup_jsonrpc(struct lightningd *ld, const char *rpc_filename)
|
||||
fd = open(rpc_filename, O_RDWR);
|
||||
if (fd == -1)
|
||||
err(1, "Opening %s", rpc_filename);
|
||||
io_new_conn(ld, fd, jcon_connected, ld);
|
||||
/* Technically this is a leak, but there's only one */
|
||||
notleak(io_new_conn(ld, fd, jcon_connected, ld));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -673,5 +677,6 @@ void setup_jsonrpc(struct lightningd *ld, const char *rpc_filename)
|
||||
err(1, "Listening on '%s'", rpc_filename);
|
||||
|
||||
log_debug(ld->log, "Listening on '%s'", rpc_filename);
|
||||
io_new_listener(ld, fd, incoming_jcon_connected, ld);
|
||||
/* Technically this is a leak, but there's only one */
|
||||
notleak(io_new_listener(ld, fd, incoming_jcon_connected, ld));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user