From: Christopher Faulet Date: Fri, 18 Jul 2025 14:07:16 +0000 (+0200) Subject: BUG/MEDIUM: hlua: Report to SC when data were consumed on a lua socket X-Git-Tag: v3.0.12~95 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=025e9ff05d093063fc7dbf20c01b77516237cf8e;p=haproxy-3.0.git BUG/MEDIUM: hlua: Report to SC when data were consumed on a lua socket The lua cosocket are quite strange. There is an applet used to handle the connection and writer and readers subscribed on it to write or read data. Writers and readers are tasks woken up by the cosocket applet when data can be consumed or produced, depending on the channels buffers state. Then the cosocket applet is woken up by writers and readers when read or write events were performed. It means the cosocket applet has only few information on what was produced or consumed. It is the writers and readers responsibility to notify any blocking. Among other things, the readers must take care to notify the stream on top of the cosocket applet that some data was consumed. Otherwise, it may remain blocked, waiting for a write event (a write event from the stream point of view is a read event from the cosocket point of view). Thie patch must be backported as far as 2.8, and maybe to 2.6 too. (cherry picked from commit 21e45a61d134786f42b046666aacced7a6ce3cc0) Signed-off-by: Willy Tarreau (cherry picked from commit 4e09e4d9d024c2e71027e7df43ed7db6c99a714f) Signed-off-by: Christopher Faulet (cherry picked from commit 60e98e90233ebceb2d9e199cd100273c65b73e15) Signed-off-by: Christopher Faulet --- diff --git a/src/hlua.c b/src/hlua.c index 967145f..0b1a7f4 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2909,7 +2909,16 @@ __LJMP static int hlua_socket_receive_yield(struct lua_State *L, int status, lua } /* Consume data. */ - co_skip(oc, len + skip_at_end); + if (len + skip_at_end) { + co_skip(oc, len + skip_at_end); + oc->flags |= CF_WRITE_EVENT | CF_WROTE_DATA; + if (s->scb->room_needed < 0 || channel_recv_max(oc) >= s->scb->room_needed) + sc_have_room(s->scb); + sc_ep_report_send_activity(s->scf); + } + else if (!s->scb->room_needed) + sc_have_room(s->scb); + /* Don't wait anything. */ applet_will_consume(appctx);