mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +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:
parent
6c951bf7e0
commit
ccb7047291
@ -16,6 +16,7 @@
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <ccan/tal/tal.h>
|
||||
#include <common/json.h>
|
||||
#include <common/memleak.h>
|
||||
#include <common/utils.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
@ -176,7 +177,8 @@ static void next_bcli(struct bitcoind *bitcoind)
|
||||
fatal("%s exec failed: %s", bcli->args[0], strerror(errno));
|
||||
|
||||
bitcoind->req_running = true;
|
||||
conn = io_new_conn(bitcoind, bcli->fd, output_init, bcli);
|
||||
/* This lifetime is attached to bitcoind command fd */
|
||||
conn = notleak(io_new_conn(bitcoind, bcli->fd, output_init, bcli));
|
||||
io_set_finish(conn, bcli_finished, bcli);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,9 @@ static void next_topology_timer(struct chain_topology *topo)
|
||||
topo->startup = false;
|
||||
io_break(topo);
|
||||
}
|
||||
new_reltimer(topo->timers, topo, topo->poll_time,
|
||||
start_poll_chaintip, topo);
|
||||
/* This takes care of its own lifetime. */
|
||||
notleak(new_reltimer(topo->timers, topo, topo->poll_time,
|
||||
start_poll_chaintip, topo));
|
||||
}
|
||||
|
||||
/* FIXME: Remove tx from block when peer done. */
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user