mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-26 14:10:59 +01:00
BUG/MEDIUM: threads/config: drop absent threads from thread groups
Thread groups can be assigned arbitrary thread ranges, but if the
mentioned threads do not exist, this causes crashes in listener_accept()
or some connections to be ignored. The reason is that the calculated
mask is derived from the thread group's enabled threads count. Examples:
global
nbthread 2
thread-groups 2
thread-group 1 1-64
thread-group 2 65-128
frontend f-crash
bind :8001 thread 1/all
frontend f-freeze
bind :8002 thread 2/all
This commit removes missing threads, emits a warning when the thread
group just has less threads than requested, and an error when it is
left with no threads at all.
This must be backported to 3.1 since the issue is present there already.
This commit is contained in:
parent
8b7a82cd30
commit
c365e47095
17
src/thread.c
17
src/thread.c
@ -1459,6 +1459,23 @@ int thread_map_to_groups()
|
||||
ha_thread_info[t].ltid_bit = 1UL << ha_thread_info[t].ltid;
|
||||
}
|
||||
|
||||
/* limit thread groups to existing threads only */
|
||||
for (g = 0; g < global.nbtgroups; g++) {
|
||||
if (ha_tgroup_info[g].base >= global.nbthread) {
|
||||
ha_alert("Thread-group %d only references non-existing threads (max=%d, requested %d-%d)\n",
|
||||
g + 1, global.nbthread, ha_tgroup_info[g].base + 1, ha_tgroup_info[g].base + ha_tgroup_info[g].count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ha_tgroup_info[g].base + ha_tgroup_info[g].count > global.nbthread) {
|
||||
ha_warning("Reducing thread-group %d to %d threads (requested %d-%d, using %d-%d)\n",
|
||||
g + 1, global.nbthread - ha_tgroup_info[g].base,
|
||||
ha_tgroup_info[g].base + 1, ha_tgroup_info[g].base + ha_tgroup_info[g].count,
|
||||
ha_tgroup_info[g].base + 1, global.nbthread);
|
||||
ha_tgroup_info[g].count = global.nbthread - ha_tgroup_info[g].base;
|
||||
}
|
||||
}
|
||||
|
||||
m = 0;
|
||||
for (g = 0; g < global.nbtgroups; g++) {
|
||||
ha_tgroup_info[g].threads_enabled = nbits(ha_tgroup_info[g].count);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user