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

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

index 9c333ac01b8fc65257da6c288d324c13778b23e7..84f85e6eb140d46c7de6b91fe6604019ca0a6e17 100644 (file)
@@ -36,6 +36,7 @@
 void sc_update_rx(struct stconn *sc);
 void sc_update_tx(struct stconn *sc);
 
+void sc_abort(struct stconn *sc);
 void sc_chk_rcv(struct stconn *sc);
 
 struct task *sc_conn_io_cb(struct task *t, void *ctx, unsigned int state);
@@ -506,13 +507,6 @@ static inline void sc_schedule_abort(struct stconn *sc)
        sc->flags |= SC_FL_ABRT_WANTED;
 }
 
-/* Abort the SC and notify the endpoint using the data layer */
-static inline void sc_abort(struct stconn *sc)
-{
-       if (likely(sc->app_ops->abort))
-               sc->app_ops->abort(sc);
-}
-
 /* Schedule a shutdown for the SC */
 static inline void sc_schedule_shutdown(struct stconn *sc)
 {
index f24297996f0ff112bf2bc9038058bdce51d074b7..50fa44313922c8c665d920098ca6ae0000eb2c60 100644 (file)
@@ -659,6 +659,47 @@ static void sc_app_abort(struct stconn *sc)
                task_wakeup(sc_strm_task(sc), TASK_WOKEN_IO);
 }
 
+/*
+ * This function performs a shutdown-read on a detached stream connector in a
+ * connected or init state (it does nothing for other states). It either shuts
+ * the read side or marks itself as closed. The buffer flags are updated to
+ * reflect the new state. If the stream connector has SC_FL_NOHALF, we also
+ * forward the close to the write side. The owner task is woken up if it exists.
+ */
+void sc_abort(struct stconn *sc)
+{
+       struct channel *ic = sc_ic(sc);
+
+       BUG_ON(!sc_strm(sc));
+
+       if (sc->flags & (SC_FL_EOS|SC_FL_ABRT_DONE))
+               return;
+
+       sc->flags |= SC_FL_ABRT_DONE;
+       ic->flags |= CF_READ_EVENT;
+
+       if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
+               return;
+
+       if (sc->flags & SC_FL_SHUT_DONE) {
+               if (sc_ep_test(sc, SE_FL_T_MUX))
+                       se_shutdown(sc->sedesc, SE_SHR_RESET|SE_SHW_SILENT);
+               else if  (sc_ep_test(sc, SE_FL_T_APPLET))
+                       se_shutdown(sc->sedesc, SE_SHR_RESET|SE_SHW_NORMAL);
+
+               sc->state = SC_ST_DIS;
+               if (sc->flags & SC_FL_ISBACK)
+                       __sc_strm(sc)->conn_exp = TICK_ETERNITY;
+       }
+       else if (sc_cond_forward_shut(sc))
+               return sc_shutdown(sc);
+
+       if (!sc_ep_test(sc, SE_FL_T_MUX|SE_FL_T_APPLET)) {
+               /* note that if the task exists, it must unregister itself once it runs */
+               if (!(sc->flags & SC_FL_DONT_WAKE))
+                       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.