Skip to content

Commit

Permalink
connectd: fix missing peer close.
Browse files Browse the repository at this point in the history
We were getting the following message in test_feerate_stress:

```
2024-07-08T02:15:45.5663941Z lightningd-2 2024-07-08T02:13:45.696Z **BROKEN** 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Peer did not close, forcing close
```

I can reproduce it locally if I run the test enough, and finally found
the issue by printing the status of the fd when we time it out (using
routines from connectd.c).

The peer fd alternates between reading and writing.  When we go to
discard it, we wake the write queue, so write_to_peer() get called.
It won't shutdown the socket if there are still subds attached, and
will wait again for a read.

The last subd exit has to also wake the write queue if we're draining,
so it can do the io_sock_shutdown.  Otherwise, we hit the timeout,
causing the message above.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jul 9, 2024
1 parent 578b297 commit 01cd605
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions connectd/multiplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,11 @@ static void destroy_subd(struct subd *subd)
* have been waiting for write_to_subd) */
io_wake(&peer->peer_in);

/* If this is the last subd, and we're draining, wake outgoing
* now (it will start shutdown). */
if (tal_count(peer->subds) == 0 && peer->to_peer && peer->draining)
msg_wake(peer->peer_outq);

/* Maybe we were last subd out? */
maybe_free_peer(peer);
}
Expand Down

0 comments on commit 01cd605

Please sign in to comment.