Skip to content

Commit 2853da1

Browse files
ddustinniftynei
authored andcommitted
connectd+: Flake/race fix for new channels
1) dualopen has fd to connectd 2) channeld needs to take over 3) dualopen passes fd that leads to a connectd over for channeld to use 4) lightningd must receive the fd transfer request and process 5) dualopen shuts down and closes everything it owns 4 & 5 end up in a race. If 5 happens before 4, channeld ends up with an invalid fd for connectd — leaving it in a position to not receive messages. Lingering for a second makes 4 win the race. Since the daemon is closing anyway, waiting for a second should be alright. Changelog-Fixed: Fixed a condition for newly created channels that could trigger a need for reconnect.
1 parent 7b506d5 commit 2853da1

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

channeld/channeld.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ static void send_shutdown_complete(struct peer *peer)
955955
wire_sync_write(MASTER_FD,
956956
take(towire_channeld_shutdown_complete(NULL)));
957957
per_peer_state_fdpass_send(MASTER_FD, peer->pps);
958+
959+
/* Give master a chance to pass the fd along */
960+
sleep(1);
961+
958962
close(MASTER_FD);
959963
}
960964

openingd/dualopend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ static void dualopen_shutdown(struct state *state)
303303
status_debug("Sent %s with fds",
304304
dualopend_wire_name(fromwire_peektype(msg)));
305305

306+
/* Give master a chance to pass the fd along */
307+
sleep(1);
308+
306309
/* This frees the entire tal tree. */
307310
tal_free(state);
308311
daemon_shutdown();
@@ -3989,6 +3992,9 @@ int main(int argc, char *argv[])
39893992
dualopend_wire_name(fromwire_peektype(msg)));
39903993
tal_free(msg);
39913994

3995+
/* Give master a chance to pass the fd along */
3996+
sleep(1);
3997+
39923998
/* This frees the entire tal tree. */
39933999
tal_free(state);
39944000
daemon_shutdown();

openingd/openingd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,9 @@ int main(int argc, char *argv[])
14841484
status_debug("Sent %s with fd",
14851485
openingd_wire_name(fromwire_peektype(msg)));
14861486

1487+
/* Give master a chance to pass the fd along */
1488+
sleep(1);
1489+
14871490
/* This frees the entire tal tree. */
14881491
tal_free(state);
14891492

0 commit comments

Comments
 (0)