diff options
-rw-r--r-- | src/server.c | 2 | ||||
-rw-r--r-- | src/signal.c | 36 | ||||
-rw-r--r-- | src/signal.h | 8 | ||||
-rw-r--r-- | src/tcp_server.c | 4 | ||||
-rw-r--r-- | src/worker.c | 2 |
5 files changed, 26 insertions, 26 deletions
diff --git a/src/server.c b/src/server.c index 2839a61..39a4aa3 100644 --- a/src/server.c +++ b/src/server.c @@ -318,7 +318,7 @@ int server_create(struct server **_server, const struct settings *settings) if (ret < 0) goto destroy_cmd_dispatcher; - ret = signalfd_listen_for_stops(); + ret = signalfd_create_sigterms(); if (ret < 0) goto destroy_event_loop; server->signalfd = ret; diff --git a/src/signal.c b/src/signal.c index d155e06..6a80e9d 100644 --- a/src/signal.c +++ b/src/signal.c @@ -16,16 +16,16 @@ #include <stddef.h> #include <sys/signalfd.h> -static int stop_signals[] = {SIGINT, SIGTERM, SIGQUIT}; +static int sigterm_signals[] = {SIGINT, SIGTERM, SIGQUIT}; -static void stops_set(sigset_t *set) +static void sigterms_mask(sigset_t *set) { sigemptyset(set); - for (size_t i = 0; i < sizeof(stop_signals) / sizeof(stop_signals[0]); ++i) - sigaddset(set, stop_signals[i]); + for (size_t i = 0; i < sizeof(sigterm_signals) / sizeof(sigterm_signals[0]); ++i) + sigaddset(set, sigterm_signals[i]); } -static int signal_set(const sigset_t *new, sigset_t *old) +static int signal_set_mask_internal(const sigset_t *new, sigset_t *old) { int ret = 0; @@ -38,23 +38,23 @@ static int signal_set(const sigset_t *new, sigset_t *old) return ret; } +int signal_set_mask(const sigset_t *new) +{ + return signal_set_mask_internal(new, NULL); +} + int signal_block_all(sigset_t *old) { sigset_t new; sigfillset(&new); - return signal_set(&new, old); + return signal_set_mask_internal(&new, old); } -int signal_block_stops(void) +int signal_block_sigterms(void) { sigset_t set; - stops_set(&set); - return signal_set(&set, NULL); -} - -int signal_restore(const sigset_t *new) -{ - return signal_set(new, NULL); + sigterms_mask(&set); + return signal_set_mask_internal(&set, NULL); } int signalfd_create(const sigset_t *set) @@ -62,7 +62,7 @@ int signalfd_create(const sigset_t *set) sigset_t old; int ret = 0; - ret = signal_set(set, &old); + ret = signal_set_mask_internal(set, &old); if (ret < 0) return ret; @@ -73,15 +73,15 @@ int signalfd_create(const sigset_t *set) return ret; restore: - signal_set(&old, NULL); + signal_set_mask_internal(&old, NULL); return ret; } -int signalfd_listen_for_stops(void) +int signalfd_create_sigterms(void) { sigset_t set; - stops_set(&set); + sigterms_mask(&set); return signalfd_create(&set); } diff --git a/src/signal.h b/src/signal.h index 0dda6ee..b049c3f 100644 --- a/src/signal.h +++ b/src/signal.h @@ -12,16 +12,16 @@ #include <signal.h> -int signal_block_all(sigset_t *old); -int signal_block_stops(void); +int signal_set_mask(const sigset_t *new); -int signal_restore(const sigset_t *new); +int signal_block_all(sigset_t *old); +int signal_block_sigterms(void); int signalfd_create(const sigset_t *); void signalfd_destroy(int fd); int signalfd_add_to_event_loop(int fd, struct event_loop *, event_handler handler, void *arg); -int signalfd_listen_for_stops(void); +int signalfd_create_sigterms(void); #endif diff --git a/src/tcp_server.c b/src/tcp_server.c index 59790b8..d763a53 100644 --- a/src/tcp_server.c +++ b/src/tcp_server.c @@ -70,7 +70,7 @@ static void *connection_thread(void *_ctx) /* Let the child thread handle its signals except those that should be * handled in the main thread. */ - ret = signal_block_stops(); + ret = signal_block_sigterms(); if (ret < 0) goto free_ctx; @@ -113,7 +113,7 @@ static int create_connection_thread(int fd, tcp_server_conn_handler conn_handler restore_mask: /* Restore the previously-enabled signals for handling in the main thread. */ - signal_restore(&old_mask); + signal_set_mask(&old_mask); return ret; diff --git a/src/worker.c b/src/worker.c index 8ecaed8..8b2af56 100644 --- a/src/worker.c +++ b/src/worker.c @@ -151,7 +151,7 @@ int worker_create(struct worker **_worker, const struct settings *settings) if (ret < 0) goto destroy_cmd_dispatcher; - ret = signalfd_listen_for_stops(); + ret = signalfd_create_sigterms(); if (ret < 0) goto destroy_event_loop; worker->signalfd = ret; |