From a7ad4aed6086995b4727777859be3f717295b7f1 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 19 Jun 2020 12:06:34 +0200 Subject: [PATCH] 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. --- src/haproxy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index 06e5a222e..8f5048636 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();