src/server/util/thrpool.c

branch
webdav
changeset 357
f45e962edf45
parent 115
51d9a15eac98
child 358
f3b490a2150c
--- a/src/server/util/thrpool.c	Sat May 14 11:18:14 2022 +0200
+++ b/src/server/util/thrpool.c	Sat May 14 12:45:59 2022 +0200
@@ -47,18 +47,21 @@
 
     pthread_mutex_init(&pool->queue_lock, NULL);
     pthread_mutex_init(&pool->avlbl_lock, NULL);
-    pthread_cond_init(&pool->available, NULL);
+    pthread_cond_init(&pool->available, NULL);  
 
+    return pool;
+}
+
+int threadpool_start(threadpool_t *pool) {
     /* create pool threads */
-    for(int i=0;i<min;i++) {
+    for(int i=0;i<pool->min_threads;i++) {
         pthread_t t;
         if (pthread_create(&t, NULL, threadpool_func, pool) != 0) {
-            perror("Error: threadpool_new: pthread_create");
-            return NULL;
+            perror("Error: threadpool_start: pthread_create");
+            return 1;
         }
     }
-
-    return pool;
+    return 0;
 }
 
 void* threadpool_func(void *data) {

mercurial