Skip to content

Commit

Permalink
connectd: don't leak fds if we have both IPv4 and IPv6.
Browse files Browse the repository at this point in the history
We accept that we will fail to listen if we bind both IPv6 and IPv4 to
the same socket on a dual-stack machine (e.g. normal Linux), but we weren't
closing the fd.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Apr 10, 2023
1 parent ed58c24 commit 3e49cb0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion connectd/connectd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1561,8 +1561,10 @@ static void connect_activate(struct daemon *daemon, const u8 *msg)
if (do_listen) {
for (size_t i = 0; i < tal_count(daemon->listen_fds); i++) {
if (listen(daemon->listen_fds[i]->fd, 64) != 0) {
if (daemon->listen_fds[i]->mayfail)
if (daemon->listen_fds[i]->mayfail) {
close(daemon->listen_fds[i]->fd);
continue;
}
errmsg = tal_fmt(tmpctx,
"Failed to listen on socket %s: %s",
type_to_string(tmpctx,
Expand Down

0 comments on commit 3e49cb0

Please sign in to comment.