Skip to content

Commit

Permalink
connectd: fix fd leak for --offline.
Browse files Browse the repository at this point in the history
```
**BROKEN** connectd: dev_report_fds: 5 open but unowned?
```

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Oct 26, 2023
1 parent 35a47c5 commit 25110ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions connectd/connectd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,9 @@ static void connect_activate(struct daemon *daemon, const u8 *msg)
->is_websocket),
daemon));
}
} else {
for (size_t i = 0; i < tal_count(daemon->listen_fds); i++)
close(daemon->listen_fds[i]->fd);
}

/* Free, with NULL assignment just as an extra sanity check. */
Expand Down
6 changes: 6 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4409,3 +4409,9 @@ def test_reconnect_no_additional_transient_failure(node_factory, bitcoind):

# We should not see a "Peer transient failure" after restart of l1
assert not l1.daemon.is_in_log(f"{l2id}-chan#1: Peer transient failure in CHANNELD_NORMAL: Disconnected", start=offset1)


def test_offline_fd_check(node_factory):
# if get_node starts it, it'll expect an address, so do it manually.
l1 = node_factory.get_node(options={"offline": None}, start=False)
l1.daemon.start()

0 comments on commit 25110ff

Please sign in to comment.