From: Aurelien DARRAGON Date: Tue, 2 May 2023 17:10:24 +0000 (+0200) Subject: BUG/MINOR: hlua: spinning loop in hlua_socket_handler() X-Git-Tag: v2.8-dev10~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2c53210454b6aad2f3c4d2c39a83310ce7df19e;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/hlua.c b/src/hlua.c index d05e9cd606..b5c9facbc1 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;