]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sc_strm: Add generic version to perform sync receives and sends
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Feb 2024 15:31:03 +0000 (16:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Mar 2024 16:28:20 +0000 (17:28 +0100)
sc_sync_recv() and sc_sync_send() were added to use connection or applet
versions, depending on the endpoint type. For now these functions are not
used. But this will be used by process_stream() to replace the connection
version.

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

index d8fb5aa7134a030bf6c31b158a2fc786a2f01620..445bbde4f2cc26b0353e098f7fc348b947e07f22 100644 (file)
@@ -43,6 +43,9 @@ void sc_conn_sync_send(struct stconn *sc);
 int sc_applet_sync_recv(struct stconn *sc);
 void sc_applet_sync_send(struct stconn *sc);
 
+int sc_applet_sync_recv(struct stconn *sc);
+void sc_applet_sync_send(struct stconn *sc);
+
 
 /* returns the channel which receives data from this stream connector (input channel) */
 static inline struct channel *sc_ic(const struct stconn *sc)
@@ -322,6 +325,30 @@ static inline void sc_chk_snd(struct stconn *sc)
                sc->app_ops->chk_snd(sc);
 }
 
+
+/* Perform a synchronous receive using the right version, depending the endpoing
+ * is a connection or an applet.
+ */
+static inline int sc_sync_recv(struct stconn *sc)
+{
+       if (sc_ep_test(sc, SE_FL_T_MUX))
+               return sc_conn_sync_recv(sc);
+       else if (sc_ep_test(sc, SE_FL_T_APPLET))
+               return sc_applet_sync_recv(sc);
+       return 0;
+}
+
+/* Perform a synchronous send using the right version, depending the endpoing is
+ * a connection or an applet.
+ */
+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))
+               sc_applet_sync_send(sc);
+}
+
 /* Combines both sc_update_rx() and sc_update_tx() at once */
 static inline void sc_update(struct stconn *sc)
 {
index 145ecf0d50b01574accca8881fea1df4e84e28b5..c6515b14e562ed01e50a81f01ff0fd0d47137a28 100644 (file)
@@ -2107,6 +2107,9 @@ int sc_applet_recv(struct stconn *sc)
  */
 int sc_applet_sync_recv(struct stconn *sc)
 {
+       if (!(__sc_appctx(sc)->flags & APPCTX_FL_INOUT_BUFS))
+               return 0;
+
        if (!sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST))
                return 0;
 
@@ -2198,6 +2201,9 @@ void sc_applet_sync_send(struct stconn *sc)
 
        oc->flags &= ~CF_WRITE_EVENT;
 
+       if (!(__sc_appctx(sc)->flags & APPCTX_FL_INOUT_BUFS))
+               return;
+
        if (sc->flags & SC_FL_SHUT_DONE)
                return;