aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-12-16 19:08:35 +0800
committerGuangxiong Lin <[email protected]>2022-12-16 19:08:35 +0800
commit1def149b9245563a8ba1db9e937d537da8de8d27 (patch)
treea4da52a57ebc29afee13242d85c386a37945c92f /src
parent7369505397cdfddf0883e2c24e1652df8bd488fe (diff)
downloadtinyserver-1def149b9245563a8ba1db9e937d537da8de8d27.tar.gz
tinyserver-1def149b9245563a8ba1db9e937d537da8de8d27.tar.bz2
tinyserver-1def149b9245563a8ba1db9e937d537da8de8d27.zip
Update default threads created
Diffstat (limited to 'src')
-rw-r--r--src/tpool.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tpool.c b/src/tpool.c
index 1aa5986..46213ff 100644
--- a/src/tpool.c
+++ b/src/tpool.c
@@ -1,5 +1,7 @@
#include <pthread.h>
#include <stdlib.h>
+#include <sys/sysinfo.h>
+
#include "tpool.h"
struct tpool_work {
@@ -102,8 +104,8 @@ tpool_t *tpool_create(size_t num)
tpool_t *tp;
pthread_t thread;
- if (num == 0)
- num = 12;
+ if (num <= 0)
+ num = get_nprocs();
tp = (tpool_t *)malloc(sizeof(*tp));
tp->thread_cnt = num;