]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: sc_strm/applet: Wake applet after a successfull synchronous send
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Sep 2024 17:12:02 +0000 (19:12 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Sep 2024 20:55:40 +0000 (22:55 +0200)
On a synchronous send from the stream to an applet, if some data were sent,
we must take care to wake the applet up. It is important because if
everything was sent at this stage, there is no other chance to wake the
applet up, mainly because SE_FL_WAIT_DATA flag is set on the applet's sedesc
in sc_update_tx() at the end of process_stream(). This flag prevent any
wakeup of the applet for a send event.

It is not necessary for a mux because the mux stream is called when a
syncrhonous send from the stream is performed. So it is reponsible to wake
the mux connection if necessary.

This patch must be backport to 3.0.

include/haproxy/sc_strm.h

index 4eaef8864f19ef4c47b2c55c28d1b97b55e958b0..7c9fb8adff0b6feba9e3fde9a6aedc4beaf2bd66 100644 (file)
@@ -348,8 +348,15 @@ static inline void sc_sync_send(struct stconn *sc)
 {
        if (sc_ep_test(sc, SE_FL_T_MUX))
                sc_conn_sync_send(sc);
-       else if (sc_ep_test(sc, SE_FL_T_APPLET))
+       else if (sc_ep_test(sc, SE_FL_T_APPLET)) {
                sc_applet_sync_send(sc);
+               if (sc_oc(sc)->flags & CF_WRITE_EVENT) {
+                       /* Data was send, wake the applet up. It is safe to do so becasuse sc_applet_sync_send()
+                        * removes CF_WRITE_EVENT flag from the channel before trying to send data to the applet.
+                        */
+                       task_wakeup(__sc_appctx(sc)->t, TASK_WOKEN_OTHER);
+               }
+       }
 }
 
 /* Combines both sc_update_rx() and sc_update_tx() at once */