]> git.ipfire.org Git - network.git/commitdiff
networkd: Add scaffolding to reload the daemon
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jan 2023 22:29:05 +0000 (22:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jan 2023 22:57:29 +0000 (22:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/daemon.c
src/networkd/daemon.h

index 483252dc493266b6941f126dd34ba3547fa3bf8e..98fb5bd55835dcc476ab2d25de8054273cdb650b 100644 (file)
@@ -34,18 +34,21 @@ struct nw_daemon {
        sd_event* loop;
 };
 
-static int nw_daemon_terminate(sd_event_source* source, const struct signalfd_siginfo* si,
+static int __nw_daemon_terminate(sd_event_source* source, const struct signalfd_siginfo* si,
                void* data) {
        DEBUG("Received signal to terminate...\n");
 
        return sd_event_exit(sd_event_source_get_event(source), 0);
 }
 
-static int nw_daemon_reload(sd_event_source* source, const struct signalfd_siginfo* si,
+static int __nw_daemon_reload(sd_event_source* source, const struct signalfd_siginfo* si,
                void* data) {
+       struct nw_daemon* daemon = (struct nw_daemon*)daemon;
+
        DEBUG("Received signal to reload...\n");
 
-       // TODO
+       // Reload the daemon
+       nw_daemon_reload(daemon);
 
        return 0;
 }
@@ -69,7 +72,7 @@ static int nw_daemon_setup_loop(struct nw_daemon* daemon) {
 
        // Listen for SIGTERM
        r = sd_event_add_signal(daemon->loop, NULL, SIGTERM|SD_EVENT_SIGNAL_PROCMASK,
-               nw_daemon_terminate, daemon);
+               __nw_daemon_terminate, daemon);
        if (r < 0) {
                ERROR("Could not register handling SIGTERM: %s\n", strerror(-r));
                return 1;
@@ -77,7 +80,7 @@ static int nw_daemon_setup_loop(struct nw_daemon* daemon) {
 
        // Listen for SIGINT
        r = sd_event_add_signal(daemon->loop, NULL, SIGINT|SD_EVENT_SIGNAL_PROCMASK,
-               nw_daemon_terminate, daemon);
+               __nw_daemon_terminate, daemon);
        if (r < 0) {
                ERROR("Could not register handling SIGINT: %s\n", strerror(-r));
                return 1;
@@ -85,7 +88,7 @@ static int nw_daemon_setup_loop(struct nw_daemon* daemon) {
 
        // Listen for SIGHUP
        r = sd_event_add_signal(daemon->loop, NULL, SIGHUP|SD_EVENT_SIGNAL_PROCMASK,
-               nw_daemon_reload, daemon);
+               __nw_daemon_reload, daemon);
        if (r < 0) {
                ERROR("Could not register handling SIGHUP: %s\n", strerror(-r));
                return 1;
@@ -167,3 +170,11 @@ int nw_daemon_run(struct nw_daemon* daemon) {
 
        return 0;
 }
+
+int nw_daemon_reload(struct nw_daemon* daemon) {
+       DEBUG("Reloading daemon...\n");
+
+       // XXX TODO
+
+       return 0;
+}
index 215972d373b3fff52bf7ef195ababfe55b3d154f..5b14ef3dff6770291823c98c7ad84ac5a7fa2874 100644 (file)
@@ -30,4 +30,6 @@ struct nw_daemon* nw_daemon_unref(struct nw_daemon* daemon);
 
 int nw_daemon_run(struct nw_daemon* daemon);
 
+int nw_daemon_reload(struct nw_daemon* daemon);
+
 #endif /* NETWORKD_DAEMON_H */