]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MINOR: threads: unbreak build with threads disabled
authorWilly Tarreau <w@1wt.eu>
Fri, 27 Jul 2018 15:14:41 +0000 (17:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 Jul 2018 15:18:22 +0000 (17:18 +0200)
Depending on the optimization level, gcc may complain that wake_thread()
uses an invalid array index for poller_wr_pipe[] when called from
__task_wakeup(). Normally the condition to get there never happens,
but it's simpler to ifdef out this part of the code which is only
used to wake other threads up. No backport is needed, this was brought
by the recent introduction of the ability to wake a sleeping thread.

src/task.c

index 6e7441f1bf689fe43a80d1744f3d8a97bee4bce4..de097baf7846220be62d46bd0a25ab8397922116 100644 (file)
@@ -71,7 +71,7 @@ void __task_wakeup(struct task *t, struct eb_root *root)
 {
        void *expected = NULL;
        int *rq_size;
-       unsigned long old_active_mask;
+       unsigned long __maybe_unused old_active_mask;
 
 #ifdef USE_THREAD
        if (root == &rqueue) {
@@ -155,6 +155,7 @@ redo:
 
                rqueue_size[nb]++;
        }
+#ifdef USE_THREAD
        /* If all threads that are supposed to handle this task are sleeping,
         * wake one.
         */
@@ -162,6 +163,7 @@ redo:
            (t->thread_mask & all_threads_mask)) &&
            !(t->thread_mask & old_active_mask))
                wake_thread(my_ffsl((t->thread_mask & all_threads_mask) &~ tid_bit) - 1);
+#endif
        return;
 }