mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
bitcoind: fix spurious memleak reports.
Turn req_running into a pointer to the current bcli structure, which means the leak detection can find it. Also suppress leaks in the case where we're only attached to a timer Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5c19c55841
commit
a80241ec7a
2 changed files with 8 additions and 8 deletions
|
@ -145,8 +145,8 @@ static void bcli_failure(struct bitcoind *bitcoind,
|
||||||
|
|
||||||
bitcoind->error_count++;
|
bitcoind->error_count++;
|
||||||
|
|
||||||
/* Retry in 1 second */
|
/* Retry in 1 second (not a leak!) */
|
||||||
new_reltimer(&bitcoind->ld->timers, bcli, time_from_sec(1),
|
new_reltimer(&bitcoind->ld->timers, notleak(bcli), time_from_sec(1),
|
||||||
retry_bcli, bcli);
|
retry_bcli, bcli);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ static void bcli_finished(struct io_conn *conn UNUSED, struct bitcoin_cli *bcli)
|
||||||
if (!bcli->exitstatus) {
|
if (!bcli->exitstatus) {
|
||||||
if (WEXITSTATUS(status) != 0) {
|
if (WEXITSTATUS(status) != 0) {
|
||||||
bcli_failure(bitcoind, bcli, WEXITSTATUS(status));
|
bcli_failure(bitcoind, bcli, WEXITSTATUS(status));
|
||||||
bitcoind->req_running = false;
|
bitcoind->current = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -179,7 +179,7 @@ static void bcli_finished(struct io_conn *conn UNUSED, struct bitcoin_cli *bcli)
|
||||||
if (WEXITSTATUS(status) == 0)
|
if (WEXITSTATUS(status) == 0)
|
||||||
bitcoind->error_count = 0;
|
bitcoind->error_count = 0;
|
||||||
|
|
||||||
bitcoind->req_running = false;
|
bitcoind->current = NULL;
|
||||||
|
|
||||||
/* Don't continue if were only here because we were freed for shutdown */
|
/* Don't continue if were only here because we were freed for shutdown */
|
||||||
if (bitcoind->shutdown)
|
if (bitcoind->shutdown)
|
||||||
|
@ -203,7 +203,7 @@ static void next_bcli(struct bitcoind *bitcoind)
|
||||||
struct bitcoin_cli *bcli;
|
struct bitcoin_cli *bcli;
|
||||||
struct io_conn *conn;
|
struct io_conn *conn;
|
||||||
|
|
||||||
if (bitcoind->req_running)
|
if (bitcoind->current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bcli = list_pop(&bitcoind->pending, struct bitcoin_cli, list);
|
bcli = list_pop(&bitcoind->pending, struct bitcoin_cli, list);
|
||||||
|
@ -215,7 +215,7 @@ static void next_bcli(struct bitcoind *bitcoind)
|
||||||
if (bcli->pid < 0)
|
if (bcli->pid < 0)
|
||||||
fatal("%s exec failed: %s", bcli->args[0], strerror(errno));
|
fatal("%s exec failed: %s", bcli->args[0], strerror(errno));
|
||||||
|
|
||||||
bitcoind->req_running = true;
|
bitcoind->current = bcli;
|
||||||
/* This lifetime is attached to bitcoind command fd */
|
/* This lifetime is attached to bitcoind command fd */
|
||||||
conn = notleak(io_new_conn(bitcoind, bcli->fd, output_init, bcli));
|
conn = notleak(io_new_conn(bitcoind, bcli->fd, output_init, bcli));
|
||||||
io_set_finish(conn, bcli_finished, bcli);
|
io_set_finish(conn, bcli_finished, bcli);
|
||||||
|
@ -802,7 +802,7 @@ struct bitcoind *new_bitcoind(const tal_t *ctx,
|
||||||
bitcoind->datadir = NULL;
|
bitcoind->datadir = NULL;
|
||||||
bitcoind->ld = ld;
|
bitcoind->ld = ld;
|
||||||
bitcoind->log = log;
|
bitcoind->log = log;
|
||||||
bitcoind->req_running = false;
|
bitcoind->current = NULL;
|
||||||
bitcoind->shutdown = false;
|
bitcoind->shutdown = false;
|
||||||
bitcoind->error_count = 0;
|
bitcoind->error_count = 0;
|
||||||
bitcoind->rpcuser = NULL;
|
bitcoind->rpcuser = NULL;
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct bitcoind {
|
||||||
struct lightningd *ld;
|
struct lightningd *ld;
|
||||||
|
|
||||||
/* Are we currently running a bitcoind request (it's ratelimited) */
|
/* Are we currently running a bitcoind request (it's ratelimited) */
|
||||||
bool req_running;
|
struct bitcoin_cli *current;
|
||||||
|
|
||||||
/* Pending requests. */
|
/* Pending requests. */
|
||||||
struct list_head pending;
|
struct list_head pending;
|
||||||
|
|
Loading…
Add table
Reference in a new issue