]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua: spinning loop in hlua_socket_handler()
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 2 May 2023 17:10:24 +0000 (19:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 May 2023 14:28:32 +0000 (16:28 +0200)
Since 3157222 ("MEDIUM: hlua/applet: Use the sedesc to report and detect
end of processing"), hlua_socket_handler() might spin loop if the hlua
socket is destroyed and some data was left unconsumed in the applet.

Prior to the above commit, the stream was explicitly KILLED
(when ctx->die == 1) so the app couldn't spinloop on unconsumed data.
But since the refactor this is no longer the case.

To prevent unconsumed data from waking the applet indefinitely, we consume
pending data when either one of EOS|ERROR|SHR|SHW flags are set, as it is
done everywhere else this check is performed in the code. Hence it was
probably overlooked in the first place during the refacto.

This bug is 2.8 specific only, so no backport needed.

src/hlua.c

index d05e9cd6068b8af5955d4c969b51fa2d02215a4b..b5c9facbc18986350d7c09f7109d33b4cec55b1d 100644 (file)
@@ -2209,6 +2209,7 @@ static void hlua_socket_handler(struct appctx *appctx)
        struct stconn *sc = appctx_sc(appctx);
 
        if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW)))) {
+               co_skip(sc_oc(sc), co_data(sc_oc(sc)));
                notification_wake(&ctx->wake_on_read);
                notification_wake(&ctx->wake_on_write);
                return;