src/server/daemon/threadpools.c

changeset 385
a1f4cb076d2f
parent 357
f45e962edf45
child 415
d938228c382e
--- a/src/server/daemon/threadpools.c	Tue Aug 13 22:14:32 2019 +0200
+++ b/src/server/daemon/threadpools.c	Sat Sep 24 16:26:10 2022 +0200
@@ -45,7 +45,7 @@
 static threadpool_t *default_io_pool;
 static threadpool_t *last_io_pool;
 
-int create_threadpool(sstr_t name, ThreadPoolConfig *cfg) { 
+int create_threadpool(scstr_t name, ThreadPoolConfig *cfg) { 
     if(thread_pool_map == NULL) {
         thread_pool_map = ucx_map_new(16);
     }
@@ -63,7 +63,12 @@
     } else {
         threadpool_t *tp = threadpool_new(cfg->min_threads, cfg->max_threads);
         
-        int ret = ucx_map_sstr_put(thread_pool_map, name, tp);
+        int ret = 0;
+        if(!threadpool_start(tp)) {
+            ret = ucx_map_sstr_put(thread_pool_map, name, tp);
+        } else {
+            ret = 1;
+        }
         
         if(ret == 0) {
             num_thrpools++;
@@ -77,7 +82,7 @@
     }
 }
 
-int create_io_pool(sstr_t name, int numthreads) {
+int create_io_pool(scstr_t name, int numthreads) {
     if(io_pool_map == NULL) {
         io_pool_map = ucx_map_new(4);
     }
@@ -110,13 +115,13 @@
         cfg.max_threads = 8;
         cfg.queue_size = 64;
         cfg.stack_size = 262144;
-        if(create_threadpool(sstr("default"), &cfg)) {
+        if(create_threadpool(SC("default"), &cfg)) {
             return 1;
         }
     }
     
     if(num_iopools == 0) {
-        if(create_io_pool(sstr("default"), 8)) {
+        if(create_io_pool(SC("default"), 8)) {
             return 1;
         }
     }

mercurial