BUG/MINOR: haproxy: only tid 0 must not sleep if got signal

This patch fixes the commit eea152ee68
("BUG/MINOR: signals/poller: ensure wakeup from signals").

There is some probability that run_poll_loop() becomes inifinite, if
TH_FL_SLEEPING is withdrawn from all threads in the second signal_queue_len
check, when a signal has received just after the first one.

In such particular case, the 'wake' variable, which is used to terminate
thread's poll loop is never reset to 0. So, we never enter to the "stopping"
part of the run_poll_loop() and threads, except the one with id 0 (tid 0
handles signals), will continue to call _do_poll() eternally and will never
sleep, as its TH_FL_SLEEPING flag was unset.

This flag needs to be removed only for the tid 0, as it was done in the first
signal_queue_len check.

This fixes an issue #2537 "infinite loop when shutting down".

This fix must be backported in every stable version.

(cherry picked from commit 4a9e3e102e192b9efd17e3241a6cc659afb7e7dc)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit 02819d2e36611d2e19c3ca084f75199c8c215067)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit c58e4a48be4dd3c3efa2bee45d00dd0174274784)
 [ad: context adjustment]
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit 722b22cf7445748a6e78a7a6594237f60f9594c0)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
1 file changed