Blob Blame History Raw
commit dfb7eb468f06dbcb9abca68c0ff3a89eb3bf80de
Author: dormando <dormando@rydia.net>
Date:   Thu Mar 26 12:51:27 2020 -0700

    fix startup segfault for low conns + idle thread
    
    < 100 connection limit plus idle_timeout feature caused a fault. Set a
    minimum sleep instead.

diff --git a/memcached.c b/memcached.c
index dd52dd0..6bfa131 100644
--- a/memcached.c
+++ b/memcached.c
@@ -341,7 +341,11 @@ static void *conn_timeout_thread(void *arg) {
     char buf[TIMEOUT_MSG_SIZE];
     rel_time_t oldest_last_cmd;
     int sleep_time;
-    useconds_t timeslice = 1000000 / (max_fds / CONNS_PER_SLICE);
+    int sleep_slice = max_fds / CONNS_PER_SLICE;
+    if (sleep_slice == 0)
+        sleep_slice = CONNS_PER_SLICE;
+
+    useconds_t timeslice = 1000000 / sleep_slice;
 
     while(do_run_conn_timeout_thread) {
         if (settings.verbose > 2)