From 669b8404d1d177d9d1e9fc646bbf1cdbb957c056 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 15 May 2023 22:59:29 +0200 Subject: signal: refactoring --- src/server.c | 2 +- src/signal.c | 14 +++++++------- src/signal.h | 6 +++--- src/tcp_server.c | 2 +- src/worker.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/server.c b/src/server.c index 273a355..ff5b9e1 100644 --- a/src/server.c +++ b/src/server.c @@ -213,7 +213,7 @@ int server_create(struct server **_server, const struct settings *settings) struct storage_settings storage_settings; int ret = 0; - ret = signal_handle_stop_signals(); + ret = signal_handle_stops(); if (ret < 0) return ret; diff --git a/src/signal.c b/src/signal.c index 0676e60..7d00bc9 100644 --- a/src/signal.c +++ b/src/signal.c @@ -35,7 +35,7 @@ static int my_sigaction(int signo, const struct sigaction *act) return ret; } -int signal_handle_stop_signals(void) +int signal_handle_stops(void) { int ret = 0; @@ -75,12 +75,7 @@ int signal_block_all(sigset_t *old) return signal_set(&new, old); } -int signal_restore(const sigset_t *new) -{ - return signal_set(new, NULL); -} - -int signal_unblock_all_except_stop_signals(void) +int signal_block_stops(void) { sigset_t set; sigemptyset(&set); @@ -90,3 +85,8 @@ int signal_unblock_all_except_stop_signals(void) return signal_set(&set, NULL); } + +int signal_restore(const sigset_t *new) +{ + return signal_set(new, NULL); +} diff --git a/src/signal.h b/src/signal.h index 713c842..4f1c280 100644 --- a/src/signal.h +++ b/src/signal.h @@ -11,11 +11,11 @@ #include extern volatile sig_atomic_t global_stop_flag; -int signal_handle_stop_signals(void); +int signal_handle_stops(void); int signal_block_all(sigset_t *old); -int signal_restore(const sigset_t *new); +int signal_block_stops(void); -int signal_unblock_all_except_stop_signals(void); +int signal_restore(const sigset_t *new); #endif diff --git a/src/tcp_server.c b/src/tcp_server.c index dbf1146..277f81e 100644 --- a/src/tcp_server.c +++ b/src/tcp_server.c @@ -62,7 +62,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_unblock_all_except_stop_signals(); + ret = signal_block_stops(); if (ret < 0) goto free_ctx; diff --git a/src/worker.c b/src/worker.c index 2771ff2..ab06563 100644 --- a/src/worker.c +++ b/src/worker.c @@ -27,7 +27,7 @@ int worker_create(struct worker **_worker) { int ret = 0; - ret = signal_handle_stop_signals(); + ret = signal_handle_stops(); if (ret < 0) return ret; -- cgit v1.2.3