MINOR: threads: move "nbthread" parsing to hathreads.c
The purpose is to make sure that all variables which directly depend
on this nbthread argument are set at the right moment. For now only
all_threads_mask needs to be set. It used to be set while calling
thread_sync_init() which is called too late for certain checks. The
same function handles threads and non-threads, which removes the need
for some thread-specific knowledge from cfgparse.c.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 9841e2d..803a918 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1190,18 +1190,10 @@
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
- global.nbthread = atol(args[1]);
-#ifndef USE_THREAD
- if (global.nbthread > 1) {
- ha_alert("HAProxy is not compiled with threads support, please check build options for USE_THREAD.\n");
- global.nbthread = 1;
- err_code |= ERR_ALERT | ERR_FATAL;
- goto out;
- }
-#endif
- if (global.nbthread < 1 || global.nbthread > MAX_THREADS) {
- ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
- file, linenum, args[0], MAX_THREADS, global.nbthread);
+ global.nbthread = parse_nbthread(args[1], &errmsg);
+ if (!global.nbthread) {
+ ha_alert("parsing [%s:%d] : '%s' %s.\n",
+ file, linenum, args[0], errmsg);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}