From a2c53210454b6aad2f3c4d2c39a83310ce7df19e Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 2 May 2023 19:10:24 +0200 Subject: [PATCH] BUG/MINOR: hlua: spinning loop in hlua_socket_handler() 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hlua.c b/src/hlua.c index d05e9cd60..b5c9facbc 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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;