From: Willy Tarreau Date: Fri, 19 Jun 2020 10:06:34 +0000 (+0200) Subject: MINOR: haproxy: process signals before runnable tasks X-Git-Tag: v2.2-dev10~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7ad4aed6086995b4727777859be3f717295b7f1;p=thirdparty%2Fhaproxy.git MINOR: haproxy: process signals before runnable tasks Nowadays signals cause tasks to be woken up. The historic code still processes signals after tasks, which forces a second round in the loop before they can effectively be processed. Let's move the signal queue handling between wake_expired_tasks() and process_runnable_tasks() where it makes much more sense. --- diff --git a/src/haproxy.c b/src/haproxy.c index 06e5a222e6..8f5048636e 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2889,13 +2889,15 @@ void run_poll_loop() while (1) { wake_expired_tasks(); - /* Process a few tasks */ - process_runnable_tasks(); - /* check if we caught some signals and process them in the first thread */ - if (tid == 0) + if (signal_queue_len && tid == 0) { + activity[tid].wake_signal++; signal_process_queue(); + } + + /* Process a few tasks */ + process_runnable_tasks(); /* also stop if we failed to cleanly stop all tasks */ if (killed > 1) @@ -2905,8 +2907,6 @@ void run_poll_loop() wake = 1; if (thread_has_tasks()) activity[tid].wake_tasks++; - else if (signal_queue_len && tid == 0) - activity[tid].wake_signal++; else { _HA_ATOMIC_OR(&sleeping_thread_mask, tid_bit); __ha_barrier_atomic_store();