Skip to content

Commit

Permalink
ctdb-tcp: Close inflight connecting TCP sockets after fork
Browse files Browse the repository at this point in the history
Commit c68b6f9 changed the talloc hierarchy such that outgoing TCP sockets
while sitting in the async connect() syscall are not freed via
ctdb_tcp_shutdown() anymore, they are hanging off a longer-running structure.
Free this structure as well.

If an outgoing TCP socket leaks into a long-running child process (possibly the
recovery daemon), this connection will never be closed as seen by the
destination node. Because with recent changes incoming connections will not be
accepted as long as any incoming connection is alive, with that socket leak
into the recovery daemon we will never again be able to successfully connect to
the node that is affected by this leak. Further attempts to connect will be
discarded by the destination as long as the recovery daemon keeps this socket
alive.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14175
RN: Avoid communication breakdown on node reconnect

Signed-off-by: Martin Schwenke <[email protected]>
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
  • Loading branch information
vlendec authored and Amitay Isaacs committed Nov 14, 2019
1 parent 231397f commit a6d99d9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ctdb/tcp/tcp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ static void ctdb_tcp_shutdown(struct ctdb_context *ctdb)
{
struct ctdb_tcp *ctcp = talloc_get_type(ctdb->private_data,
struct ctdb_tcp);
uint32_t i;

talloc_free(ctcp);
ctdb->private_data = NULL;

for (i=0; i<ctdb->num_nodes; i++) {
TALLOC_FREE(ctdb->nodes[i]->private_data);
}
}

/*
Expand Down

0 comments on commit a6d99d9

Please sign in to comment.