tools/gossipwith: shutdown, don't close, TCP socket.

This isn't the cause of the test_gossip_ratelimit flake I saw (since
the final gossip msg clearly was received), but it's still good to fix
since it means we might not send the final messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-06-19 14:07:54 +09:30
parent 7820dfdb35
commit c1d3da889c

View File

@@ -246,6 +246,15 @@ static struct io_plan *handshake_success(struct io_conn *conn,
--max_messages;
}
}
/* Simply closing the fd can lose writes; send shutdown and wait
* for them to close (set alarm just in case!) */
alarm(30);
if (shutdown(peer_fd, SHUT_WR) != 0)
err(1, "failed to shutdown write to peer: %s", strerror(errno));
while (sync_crypto_read(NULL, peer_fd, cs));
exit(0);
}