MINOR: threads: Add nbthread parameter
It is only parsed and initialized for now. It will be used later. This parameter is only available when support for threads was built in.
This commit is contained in:
parent
415f611ff4
commit
be0faa2e47
@ -542,6 +542,7 @@ The following keywords are supported in the "global" section :
|
||||
- log-send-hostname
|
||||
- lua-load
|
||||
- nbproc
|
||||
- nbthread
|
||||
- node
|
||||
- pidfile
|
||||
- presetenv
|
||||
@ -826,6 +827,13 @@ nbproc <number>
|
||||
process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
|
||||
IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
|
||||
|
||||
nbthread <number>
|
||||
This setting is only available when support for threads was built in. It
|
||||
creates <number> threads for each created processes. It means if HAProxy is
|
||||
started in foreground, it only creates <number> threads for the first
|
||||
process. FOR NOW, THREADS SUPPORT IN HAPROXY IS HIGHLY EXPERIMENTAL AND IT
|
||||
MUST BE ENABLED WITH CAUTION AND AT YOUR OWN RISK. See also "nbproc".
|
||||
|
||||
pidfile <pidfile>
|
||||
Writes pids of all daemons into file <pidfile>. This option is equivalent to
|
||||
the "-p" command line argument. The file must be accessible to the user
|
||||
|
@ -86,6 +86,7 @@ struct global {
|
||||
int gid;
|
||||
int external_check;
|
||||
int nbproc;
|
||||
int nbthread;
|
||||
unsigned int hard_stop_after; /* maximum time allowed to perform a soft-stop */
|
||||
int maxconn, hardmaxconn;
|
||||
int maxsslconn;
|
||||
|
@ -1041,6 +1041,30 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(args[0], "nbthread")) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
if (*(args[1]) == 0) {
|
||||
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
global.nbthread = atol(args[1]);
|
||||
if (global.nbthread < 1 || global.nbthread > LONGBITS) {
|
||||
Alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
|
||||
file, linenum, args[0], LONGBITS, global.nbthread);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
#ifndef USE_THREAD
|
||||
if (global.nbthread > 1) {
|
||||
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
|
||||
}
|
||||
else if (!strcmp(args[0], "maxconn")) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
|
@ -77,6 +77,7 @@
|
||||
#include <common/time.h>
|
||||
#include <common/uri_auth.h>
|
||||
#include <common/version.h>
|
||||
#include <common/hathreads.h>
|
||||
|
||||
#include <types/capture.h>
|
||||
#include <types/filters.h>
|
||||
@ -122,6 +123,7 @@ int relative_pid = 1; /* process id starting at 1 */
|
||||
struct global global = {
|
||||
.hard_stop_after = TICK_ETERNITY,
|
||||
.nbproc = 1,
|
||||
.nbthread = 1,
|
||||
.req_count = 0,
|
||||
.logsrvs = LIST_HEAD_INIT(global.logsrvs),
|
||||
.maxzlibmem = 0,
|
||||
@ -1754,6 +1756,9 @@ static void init(int argc, char **argv)
|
||||
if (global.nbproc < 1)
|
||||
global.nbproc = 1;
|
||||
|
||||
if (global.nbthread < 1)
|
||||
global.nbthread = 1;
|
||||
|
||||
/* Realloc trash buffers because global.tune.bufsize may have changed */
|
||||
if (!init_trash_buffers()) {
|
||||
Alert("failed to initialize trash buffers.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user