51bd1a
commit 48c2d30efef24270ea94fa133945b8ecd3a015e3
51bd1a
Author: Tomas Korbar <tkorbar@redhat.com>
51bd1a
Date:   Wed May 20 15:28:10 2020 +0200
51bd1a
51bd1a
    Do not join lru and slab maintainer threads if they do not exist
51bd1a
    
51bd1a
    If no_modern option was supplied then these threads did not run
51bd1a
    but memcached still attempted to join them, which resulted in a
51bd1a
    segfault.
51bd1a
    
51bd1a
    resolve #685
51bd1a
51bd1a
diff --git a/thread.c b/thread.c
51bd1a
index f162d26..abbfca1 100644
51bd1a
--- a/thread.c
51bd1a
+++ b/thread.c
51bd1a
@@ -226,12 +226,16 @@ void stop_threads(void) {
51bd1a
     stop_item_crawler_thread(CRAWLER_WAIT);
51bd1a
     if (settings.verbose > 0)
51bd1a
         fprintf(stderr, "stopped lru crawler\n");
51bd1a
-    stop_lru_maintainer_thread();
51bd1a
-    if (settings.verbose > 0)
51bd1a
-        fprintf(stderr, "stopped maintainer\n");
51bd1a
-    stop_slab_maintenance_thread();
51bd1a
-    if (settings.verbose > 0)
51bd1a
-        fprintf(stderr, "stopped slab mover\n");
51bd1a
+    if (settings.lru_maintainer_thread) {
51bd1a
+        stop_lru_maintainer_thread();
51bd1a
+        if (settings.verbose > 0)
51bd1a
+            fprintf(stderr, "stopped maintainer\n");
51bd1a
+    }
51bd1a
+    if (settings.slab_reassign) {
51bd1a
+        stop_slab_maintenance_thread();
51bd1a
+        if (settings.verbose > 0)
51bd1a
+            fprintf(stderr, "stopped slab mover\n");
51bd1a
+    }
51bd1a
     logger_stop();
51bd1a
     if (settings.verbose > 0)
51bd1a
         fprintf(stderr, "stopped logger thread\n");