]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: rhttp: fix preconnect on single-thread
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 21 May 2024 14:35:28 +0000 (16:35 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 22 May 2024 08:01:57 +0000 (10:01 +0200)
On initialization of a rhttp bind, the first thread available on the
listener is selected to execute the first occurence of the preconnect
task.

This thread selection was incorrect as it used my_ffsl() which returns
value indexed from 1, contrary to tid which are indexed from 0. This
cause the first listener thread to be skipped in favor of the second
one. Worst, if haproxy runs in single-thread mode, calculated thread ID
will be invalid and the task will never run, which prevent any
preconnect execution.

Fix this by substracting the result of my_ffsl() by 1 to have a value
indexed from 0.

This must be backported up to 2.9.

src/proto_rhttp.c

index 05611e0e538dece3e177d1160a68fbabf51d78e8..e5064774f7461d9c0380749148859402235c1d6b 100644 (file)
@@ -291,7 +291,7 @@ int rhttp_bind_listener(struct listener *listener, char *errmsg, int errlen)
 
        /* Retrieve the first thread usable for this listener. */
        mask = listener->rx.bind_thread & _HA_ATOMIC_LOAD(&tg->threads_enabled);
-       task_tid = my_ffsl(mask) + ha_tgroup_info[listener->rx.bind_tgroup].base;
+       task_tid = my_ffsl(mask) - 1 + ha_tgroup_info[listener->rx.bind_tgroup].base;
        if (!(task = task_new_on(task_tid))) {
                snprintf(errmsg, errlen, "Out of memory.");
                goto err;