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