]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Close server socket when switching to client
authorMartin Schwenke <martin@meltin.net>
Tue, 19 May 2020 07:57:35 +0000 (17:57 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 25 Jun 2021 09:16:31 +0000 (09:16 +0000)
The socket is set close-on-exec but that doesn't help for processes
that do not exec().  This should be done for all child processes.

This has been seen in testing where "ctdb shutdown" waits for the
socket to close before succeeding.  It appears that lingering
vacuuming processes have not closed the socket when becoming clients
so they cause "ctdb shutdown" to hang even though the main daemon
process has exited.  The cause of the lingering vacuuming processes
has been previously examined but still isn't understood.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_daemon.c

index 9035f5b4748ae3b79762e08c12b4a4284ad4006a..57f80235e7c8b615baf607cdb769f3d0048a1b9d 100644 (file)
@@ -2179,6 +2179,11 @@ int switch_from_server_to_client(struct ctdb_context *ctdb)
 {
        int ret;
 
+       if (ctdb->daemon.sd != -1) {
+               close(ctdb->daemon.sd);
+               ctdb->daemon.sd = -1;
+       }
+
        /* get a new event context */
        ctdb->ev = tevent_context_init(ctdb);
        if (ctdb->ev == NULL) {