]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: applet: Don't trigger BUG_ON if the tid is not on appctx init
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Jul 2025 09:29:49 +0000 (11:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Jul 2025 11:47:33 +0000 (13:47 +0200)
When an appctx is initialized, there is a BUG_ON() to be sure the appctx is
really initialized on the right thread to avoid bugs on the thread
affinity. However, it is possible to not choose the thread when the appctx
is created and let it starts on any thread. In that case, the thread
affinity is set when the appctx is initialized. So, we must take cate to not
trigger the BUG_ON() in that case.

For now, we never hit the bug because the thread affinity is always set
during the appctx creation.

This patch must be backport as far as 2.8.

include/haproxy/applet.h

index e9357e773611b46ac1a8788e50ddf0bc3a15bf04..65e1af67ea86d413dab6913b552203819474572a 100644 (file)
@@ -116,7 +116,7 @@ static inline int appctx_init(struct appctx *appctx)
         * the appctx will be fully initialized. The session and the stream will
         * eventually be created. The affinity must be set now !
         */
-       BUG_ON(appctx->t->tid != tid);
+       BUG_ON(appctx->t->tid != -1 && appctx->t->tid != tid);
        task_set_thread(appctx->t, tid);
 
        if (appctx->applet->init)