]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
sd_notify(3): set the MONOTONIC_USEC field with RELOADING=1
authorAram Sargsyan <aram@isc.org>
Thu, 19 Oct 2023 12:57:13 +0000 (12:57 +0000)
committerAram Sargsyan <aram@isc.org>
Mon, 23 Oct 2023 13:27:59 +0000 (13:27 +0000)
When using sd_notify(3) to send a message to the service manager
about named being reloaded, systemd also requires the MONOTONIC_USEC
field to be set to the current monotonic time in microseconds,
otherwise the 'systemctl reload' command fails.

Add the MONOTONIC_USEC field to the message.

See 'man 5 systemd.service' for more information.

bin/named/server.c

index f23e28547aee62eb7fffe27c948566b3020807c4..9333d206c85467a8eff53ea5709fd2bd8fb787d0 100644 (file)
@@ -59,6 +59,7 @@
 #include <isc/stats.h>
 #include <isc/stdio.h>
 #include <isc/string.h>
+#include <isc/time.h>
 #include <isc/timer.h>
 #include <isc/util.h>
 
@@ -10287,8 +10288,15 @@ reload(named_server_t *server) {
 
        atomic_store(&server->reload_status, NAMED_RELOAD_IN_PROGRESS);
 #if HAVE_LIBSYSTEMD
-       sd_notify(0, "RELOADING=1\n"
-                    "STATUS=reload command received\n");
+       char buf[512];
+       int n = snprintf(buf, sizeof(buf),
+                        "RELOADING=1\n"
+                        "MONOTONIC_USEC=%" PRIu64 "\n"
+                        "STATUS=reload command received\n",
+                        (uint64_t)isc_time_monotonic() / NS_PER_US);
+       if (n > 0 && (size_t)n < sizeof(buf)) {
+               sd_notify(0, buf);
+       }
 #endif /* HAVE_LIBSYSTEMD */
 
        CHECK(loadconfig(server));
@@ -10668,8 +10676,15 @@ named_server_reconfigcommand(named_server_t *server) {
        isc_result_t result;
        atomic_store(&server->reload_status, NAMED_RELOAD_IN_PROGRESS);
 #if HAVE_LIBSYSTEMD
-       sd_notify(0, "RELOADING=1\n"
-                    "STATUS=reconfig command received\n");
+       char buf[512];
+       int n = snprintf(buf, sizeof(buf),
+                        "RELOADING=1\n"
+                        "MONOTONIC_USEC=%" PRIu64 "\n"
+                        "STATUS=reconfig command received\n",
+                        (uint64_t)isc_time_monotonic() / NS_PER_US);
+       if (n > 0 && (size_t)n < sizeof(buf)) {
+               sd_notify(0, buf);
+       }
 #endif /* HAVE_LIBSYSTEMD */
 
        CHECK(loadconfig(server));