From 8bb9d9a3e5ca93c38db97181d4c15b03d48a644d Mon Sep 17 00:00:00 2001 From: dormando Date: Tue, 10 Jan 2023 15:55:16 -0800 Subject: core: do not stop threads on SIGINT/SIGTERM A change was accidentally introduced where part of the graceful shutdown code (stop_threads() -> close_conns()) would execute during non-graceful shutdown (INT/TERM). This could lead to hangs or bugs if using code that does not support graceful shutdown (proxy). This does not restore the old method of immediately exiting, and still frees some memory and returns from main(), but it no longer attempts to stop all the worker threads. --- memcached.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/memcached.c b/memcached.c index 2c17713..084aafd 100644 --- a/memcached.c +++ b/memcached.c @@ -6233,7 +6233,7 @@ int main (int argc, char **argv) { // if we want to. if (settings.verbose) { - fprintf(stderr, "Signal handled\n"); + fprintf(stderr, "Exiting normally\n"); } break; @@ -6242,9 +6242,11 @@ int main (int argc, char **argv) { break; } - stop_threads(); - if (settings.memory_file != NULL && stop_main_loop == GRACE_STOP) { - restart_mmap_close(); + if (stop_main_loop == GRACE_STOP) { + stop_threads(); + if (settings.memory_file != NULL) { + restart_mmap_close(); + } } /* remove the PID file if we're a daemon */ -- cgit v1.2.1