# HG changeset patch
# User Olaf Wintermann <olaf.wintermann@gmail.com>
# Date 1652525465 -7200
# Node ID f3b490a2150cb57b7431fb5be2e5ea55fd58c0fa
# Parent  f45e962edf457d99e76f15a4909a7ee2ab579bfc
start threadpool in threadpool_run() if no threads are created yet

diff -r f45e962edf45 -r f3b490a2150c src/server/util/thrpool.c
--- a/src/server/util/thrpool.c	Sat May 14 12:45:59 2022 +0200
+++ b/src/server/util/thrpool.c	Sat May 14 12:51:05 2022 +0200
@@ -106,6 +106,12 @@
 }
 
 void threadpool_run(threadpool_t *pool, job_callback_f func, void *data) {
+    // TODO: handle errors
+    
+    if(pool->num_threads == 0) {
+        threadpool_start(pool);
+    }
+    
     threadpool_job *job = malloc(sizeof(threadpool_job));
     job->callback = func;
     job->data = data;