From 871a7b0853eabe8d77a1aa6e866f6e3a804a2b77 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 15 May 2023 17:18:22 +0200 Subject: EINVAL means EINTR also? --- src/server.c | 2 +- src/worker.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server.c b/src/server.c index bf6a967..67f9e17 100644 --- a/src/server.c +++ b/src/server.c @@ -404,7 +404,7 @@ static int server_listen_thread(struct server *server) ret = tcp_server_accept(server->tcp_server, cmd_dispatcher_handle_conn, dispatcher); if (ret < 0) { - if (errno == EINVAL && global_stop_flag) + if ((errno == EINTR || errno == EINVAL) && global_stop_flag) ret = 0; goto dispatcher_destroy; } diff --git a/src/worker.c b/src/worker.c index 5762549..a316d7f 100644 --- a/src/worker.c +++ b/src/worker.c @@ -135,8 +135,11 @@ int worker_main(UNUSED struct worker *worker, const struct settings *settings) log("Waiting for a new command\n"); ret = worker_send_new_worker(settings, &task); - if (ret < 0) + if (ret < 0) { + if ((errno == EINTR || errno == EINVAL) && global_stop_flag) + ret = 0; goto dispatcher_destroy; + } while (!global_stop_flag) { struct msg *result = NULL; @@ -148,8 +151,11 @@ int worker_main(UNUSED struct worker *worker, const struct settings *settings) ret = worker_send_to_server(settings, result, &task); msg_free(result); - if (ret < 0) + if (ret < 0) { + if ((errno == EINTR || errno == EINVAL) && global_stop_flag) + ret = 0; goto dispatcher_destroy; + } } dispatcher_destroy: -- cgit v1.2.3