Skip to content

Commit

Permalink
lightningd: fix race in initialization.
Browse files Browse the repository at this point in the history
Found by very slow CI: the two io_breaks() can combine into one, so we
block waiting for the second initialization which never happens.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jun 24, 2024
1 parent 9da6610 commit 80cde51
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lightningd/chaintopology.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,15 +1400,19 @@ void setup_topology(struct chain_topology *topo)
db_commit_transaction(topo->ld->wallet->db);

/* Sanity checks, then topology initialization. */
chaininfo->chain = NULL;
feerates->rates = NULL;
bitcoind_getchaininfo(chaininfo, topo->bitcoind, blockscan_start,
get_chaininfo_once, chaininfo);
bitcoind_estimate_fees(feerates, topo->bitcoind, get_feerates_once, feerates);

/* Each one will break, order doesn't matter */
ret = io_loop_with_timers(topo->ld);
assert(ret == topo);
/* Each one will break, but they might only exit once! */
ret = io_loop_with_timers(topo->ld);
assert(ret == topo);
if (chaininfo->chain == NULL || feerates->rates == NULL) {
ret = io_loop_with_timers(topo->ld);
assert(ret == topo);
}

topo->headercount = chaininfo->headercount;
if (!streq(chaininfo->chain, chainparams->bip70_name))
Expand Down

0 comments on commit 80cde51

Please sign in to comment.