mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-26 15:40:32 +00:00
BUG/MEDIUM: threads: unbreak "bind" referencing an incorrect thread number
The "process" directive on "bind" lines supports process references and thread references. No check is performed on the thread number validity, so that if a listener is only bound to non-existent threads, the traffic will never be processed. It easily happens when setting one bind line per thread with an incorrect (or reduced) thread count. No warning appears and some random connections are never served. It also happens when setting thread references with threads support disabled at build time. This patch makes use of the all_threads_mask variable to detect if some referenced threads don't exist, to emit a warning and fix this. This patch needs to be backported to 1.8, just like the previous one which it depends on (MINOR: threads: move "nbthread" parsing to hathreads.c).
This commit is contained in:
parent
0ccd32285f
commit
c477b6fcc9
@ -7581,6 +7581,29 @@ int check_config_validity()
|
||||
} /* HTTP && bufsize < 16384 */
|
||||
#endif
|
||||
|
||||
/* detect and address thread affinity inconsistencies */
|
||||
nbproc = 0;
|
||||
if (bind_conf->bind_proc)
|
||||
nbproc = my_ffsl(bind_conf->bind_proc);
|
||||
|
||||
mask = bind_conf->bind_thread[nbproc - 1];
|
||||
if (mask && !(mask & (all_threads_mask ? all_threads_mask : 1UL))) {
|
||||
unsigned long new_mask = 0;
|
||||
|
||||
while (mask) {
|
||||
new_mask |= mask & (all_threads_mask ? all_threads_mask : 1UL);
|
||||
mask >>= global.nbthread;
|
||||
}
|
||||
|
||||
for (nbproc = 0; nbproc < LONGBITS; nbproc++) {
|
||||
if (!bind_conf->bind_proc || (bind_conf->bind_proc & (1UL << nbproc)))
|
||||
bind_conf->bind_thread[nbproc] = new_mask;
|
||||
}
|
||||
ha_warning("Proxy '%s': the thread range specified on the 'process' directive of 'bind %s' at [%s:%d] only refers to thread numbers out of the range defined by the global 'nbthread' directive. The thread numbers were remapped to existing threads instead (mask 0x%lx).\n",
|
||||
curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line, new_mask);
|
||||
}
|
||||
|
||||
/* detect process and nbproc affinity inconsistencies */
|
||||
if (!bind_conf->bind_proc)
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user