ctdb-daemon: Enable log reopening for recovery daemon
authorMartin Schwenke <martin@meltin.net>
Thu, 30 Sep 2021 11:08:25 +0000 (21:08 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 17 Jan 2022 03:43:30 +0000 (03:43 +0000)
Pass on a SIGHUP to the recovery daemon, which will then reopen its
logs.

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

index 482a67ef253d4042cf0c1a651aaf907eaa1aa9c8..d0f3a8ae1a358352355e31a7880edcf8d2aaa8fd 100644 (file)
@@ -1488,6 +1488,16 @@ static void fork_only(void)
        }
 }
 
+static void sighup_hook(void *private_data)
+{
+       struct ctdb_context *ctdb = talloc_get_type_abort(private_data,
+                                                         struct ctdb_context);
+
+       if (ctdb->recoverd_pid > 0) {
+               kill(ctdb->recoverd_pid, SIGHUP);
+       }
+}
+
 /*
   start the protocol going as a daemon
 */
@@ -1551,8 +1561,8 @@ int ctdb_start_daemon(struct ctdb_context *ctdb,
 
        status = logging_setup_sighup_handler(ctdb->ev,
                                              ctdb,
-                                             NULL,
-                                             NULL);
+                                             sighup_hook,
+                                             ctdb);
        if (!status) {
                D_ERR("Failed to set up signal handler for SIGHUP\n");
                exit(1);