From 156edd022ef315eb68e0f7002994dfeb172a25c1 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 6 May 2023 15:54:55 +0200 Subject: shut down server/workers gracefully on SIGTERM --- src/server.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/server.c') diff --git a/src/server.c b/src/server.c index 33610f3..51ee27f 100644 --- a/src/server.c +++ b/src/server.c @@ -393,8 +393,13 @@ int server_main(struct server *server) log("Waiting for new connections\n"); ret = tcp_server_accept(server->tcp_server, server_conn_handler, server); - if (ret < 0) - break; + if (ret < 0) { + if (errno == EINVAL && global_stop_flag) { + ret = 0; + break; + } + return ret; + } } return server_set_stopping(server); -- cgit v1.2.3