src/server/util/thrpool.c

changeset 577
4f5ccaea4a92
parent 576
5c31cc844c68
--- a/src/server/util/thrpool.c	Fri Jan 31 21:27:54 2025 +0100
+++ b/src/server/util/thrpool.c	Sat Feb 01 09:23:14 2025 +0100
@@ -254,12 +254,6 @@
     while(t < end || i < 2) {
         uint32_t num_threads = pool->num_threads;
         if(num_threads == 0) {
-            // it's possible that we send too many kill jobs, cleanup the queue
-            while(pool->queue) {
-                pool_queue_t *q = pool->queue->next;
-                free(pool->queue);
-                pool->queue = q;
-            }
             break;
         }
         
@@ -269,7 +263,18 @@
         t = time(NULL);
     }
     
-    if(pool->num_threads) {
+    if(pool->num_threads == 0) {
+        // it's possible that we send too many kill jobs, cleanup the queue
+        while(pool->queue) {
+            pool_queue_t *q = pool->queue->next;
+            free(pool->queue);
+            pool->queue = q;
+        }
+        
+        free(pool->threads);
+        free(pool->thrstatus);
+        free(pool);
+        
         log_ereport(LOG_VERBOSE, "threadpool_shutdown successful");
     } else if(t > end) {
         log_ereport(LOG_WARN, "threadpool_shutdown: timeout");

mercurial