]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: haproxy: process signals before runnable tasks
authorWilly Tarreau <w@1wt.eu>
Fri, 19 Jun 2020 10:06:34 +0000 (12:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 19 Jun 2020 12:21:46 +0000 (14:21 +0200)
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

index 06e5a222e6a79bbec50bab2cfb3b050268026b1c..8f5048636e2f3762e0466031d54cb077d0ddc04b 100644 (file)
@@ -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();