diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-06-13 03:59:41 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-06-13 03:59:41 +0200 |
commit | 349846cd411f0c6d45237c5794f9694cb6030489 (patch) | |
tree | 85e2247cc4dc7cbbfb3465a61385d5f484005a7e | |
parent | server: handle disconnected workers gracefully (diff) | |
download | cimple-349846cd411f0c6d45237c5794f9694cb6030489.tar.gz cimple-349846cd411f0c6d45237c5794f9694cb6030489.zip |
signal: remove the stupid add_to_event_loop wrapper
Diffstat (limited to '')
-rw-r--r-- | src/server.c | 5 | ||||
-rw-r--r-- | src/signal.c | 7 | ||||
-rw-r--r-- | src/signal.h | 7 | ||||
-rw-r--r-- | src/worker.c | 4 |
4 files changed, 6 insertions, 17 deletions
diff --git a/src/server.c b/src/server.c index 0e771df..cd77dc8 100644 --- a/src/server.c +++ b/src/server.c @@ -19,6 +19,7 @@ #include "tcp_server.h" #include "worker_queue.h" +#include <poll.h> #include <pthread.h> #include <stdlib.h> @@ -317,8 +318,8 @@ int server_create(struct server **_server, const struct settings *settings) goto destroy_event_loop; server->signalfd = ret; - ret = signalfd_add_to_event_loop(server->signalfd, server->event_loop, server_set_stopping, - server); + ret = event_loop_add(server->event_loop, server->signalfd, POLLIN, server_set_stopping, + server); if (ret < 0) goto close_signalfd; diff --git a/src/signal.c b/src/signal.c index 1f4a9cc..15d90ab 100644 --- a/src/signal.c +++ b/src/signal.c @@ -7,11 +7,9 @@ #include "signal.h" #include "compiler.h" -#include "event_loop.h" #include "file.h" #include "log.h" -#include <poll.h> #include <signal.h> #include <stddef.h> #include <sys/signalfd.h> @@ -89,8 +87,3 @@ void signalfd_destroy(int fd) { file_close(fd); } - -int signalfd_add_to_event_loop(int fd, struct event_loop *loop, event_handler handler, void *arg) -{ - return event_loop_add(loop, fd, POLLIN, handler, arg); -} diff --git a/src/signal.h b/src/signal.h index b049c3f..e48eff2 100644 --- a/src/signal.h +++ b/src/signal.h @@ -8,8 +8,6 @@ #ifndef __SIGNAL_H__ #define __SIGNAL_H__ -#include "event_loop.h" - #include <signal.h> int signal_set_mask(const sigset_t *new); @@ -18,10 +16,7 @@ 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_create_sigterms(void); +void signalfd_destroy(int fd); #endif diff --git a/src/worker.c b/src/worker.c index 725fad7..03a83c6 100644 --- a/src/worker.c +++ b/src/worker.c @@ -153,8 +153,8 @@ int worker_create(struct worker **_worker, const struct settings *settings) goto destroy_event_loop; worker->signalfd = ret; - ret = signalfd_add_to_event_loop(worker->signalfd, worker->event_loop, worker_set_stopping, - worker); + ret = event_loop_add(worker->event_loop, worker->signalfd, POLLIN, worker_set_stopping, + worker); if (ret < 0) goto close_signalfd; |