]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stconn: Merge all .chk_rcv() callback functions in sc_chk_rcv()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 Mar 2026 17:03:34 +0000 (18:03 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Mar 2026 14:10:34 +0000 (15:10 +0100)
sc_chk_rcv() is no longer relying on .chk_rcv() callback functions.
Everything was merged in sc_chk_rcv() with a test on the app type.

include/haproxy/sc_strm.h
src/stconn.c

index c0e91201d8fbd013f9940b16e1876ae4d6e6ab95..ebc2becbd251d2991bddb30fc9d5292a6130782c 100644 (file)
@@ -36,6 +36,8 @@
 void sc_update_rx(struct stconn *sc);
 void sc_update_tx(struct stconn *sc);
 
+void sc_chk_rcv(struct stconn *sc);
+
 struct task *sc_conn_io_cb(struct task *t, void *ctx, unsigned int state);
 int sc_conn_sync_recv(struct stconn *sc);
 int sc_conn_sync_send(struct stconn *sc);
@@ -360,31 +362,6 @@ static inline int sc_is_recv_allowed(const struct stconn *sc)
        return !(sc->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM));
 }
 
-/* This is to be used after making some room available in a channel. It will
- * return without doing anything if the stream connector's RX path is blocked.
- * It will automatically mark the stream connector as busy processing the end
- * point in order to avoid useless repeated wakeups.
- * It will then call ->chk_rcv() to enable receipt of new data.
- */
-static inline void sc_chk_rcv(struct stconn *sc)
-{
-       if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN) &&
-           sc_state_in(sc_opposite(sc)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) {
-               sc_ep_clr(sc, SE_FL_APPLET_NEED_CONN);
-               sc_ep_report_read_activity(sc);
-       }
-
-       if (!sc_is_recv_allowed(sc))
-               return;
-
-       if (!sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST))
-               return;
-
-       sc_ep_set(sc, SE_FL_HAVE_NO_DATA);
-       if (likely(sc->app_ops->chk_rcv))
-               sc->app_ops->chk_rcv(sc);
-}
-
 /* Calls chk_snd on the endpoint using the data layer */
 static inline void sc_chk_snd(struct stconn *sc)
 {
index 0c641e50fd8bbb96eb48e2b7a670557305265843..a1aedeb312944274bd9615adf9ecff9689b8f2eb 100644 (file)
@@ -675,6 +675,46 @@ static void sc_app_abort(struct stconn *sc)
                task_wakeup(sc_strm_task(sc), TASK_WOKEN_IO);
 }
 
+
+/* This is to be used after making some room available in a channel. It will
+ * return without doing anything if the stream connector's RX path is blocked.
+ * It will automatically mark the stream connector as busy processing the end
+ * point in order to avoid useless repeated wakeups.
+ * It will then woken the right entity to enable receipt of new data.
+ */
+void sc_chk_rcv(struct stconn *sc)
+{
+       BUG_ON(!sc_strm(sc));
+
+       if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN) &&
+           sc_state_in(sc_opposite(sc)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) {
+               sc_ep_clr(sc, SE_FL_APPLET_NEED_CONN);
+               sc_ep_report_read_activity(sc);
+       }
+
+       if (!sc_is_recv_allowed(sc))
+               return;
+
+       if (!sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST))
+               return;
+
+       sc_ep_set(sc, SE_FL_HAVE_NO_DATA);
+
+       /* (re)start reading */
+       if (sc_ep_test(sc, SE_FL_T_MUX)) {
+               if (sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
+                       tasklet_wakeup(sc->wait_event.tasklet, TASK_WOKEN_IO);
+       }
+       else if  (sc_ep_test(sc, SE_FL_T_APPLET)) {
+               if (!sc_ep_have_ff_data(sc_opposite(sc)))
+                       appctx_wakeup(__sc_appctx(sc));
+       }
+       else {
+               if (!(sc->flags & SC_FL_DONT_WAKE))
+                       task_wakeup(sc_strm_task(sc), TASK_WOKEN_IO);
+       }
+}
+
 /*
  * This function performs a shutdown-write on a detached stream connector in a
  * connected or init state (it does nothing for other states). It either shuts