]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: conn-stream/connection: Move SHR/SHW modes in the connection scope
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 31 Mar 2022 09:05:05 +0000 (11:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:15 +0000 (15:10 +0200)
These flags only concerns the connection part. In addition, it is required
for a next commit, to avoid circular deps. Thus CS_SHR_* and CS_SHW_* were
renamed with the "CO_" prefix.

include/haproxy/conn_stream-t.h
include/haproxy/conn_stream.h
include/haproxy/connection-t.h
include/haproxy/stream-t.h
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c
src/stream_interface.c

index fb0aa503d1d9fa77533b3f6b98c7685e971c6c33..a1e35389f2b5d6b1d6cadbfaf40f2261c9f6074d 100644 (file)
@@ -24,6 +24,7 @@
 #define _HAPROXY_CONN_STREAM_T_H
 
 #include <haproxy/obj_type-t.h>
+#include <haproxy/connection-t.h>
 
 struct stream_interface;
 
@@ -89,18 +90,6 @@ enum {
        CS_FL_INDEP_STR     = 0x00000040,  /* independent streams = don't update rex on write */
 };
 
-/* cs_shutr() modes */
-enum cs_shr_mode {
-       CS_SHR_DRAIN        = 0,           /* read shutdown, drain any extra stuff */
-       CS_SHR_RESET        = 1,           /* read shutdown, reset any extra stuff */
-};
-
-/* cs_shutw() modes */
-enum cs_shw_mode {
-       CS_SHW_NORMAL       = 0,           /* regular write shutdown */
-       CS_SHW_SILENT       = 1,           /* imminent close, don't notify peer */
-};
-
 /* A conn stream must have its own errors independently of the buffer's, so that
  * applications can rely on what the buffer reports while the conn stream is
  * performing some retries (eg: connection error). Some states are transient and
index aa708c75a913d52cb24376b926f2477f94d35a3e..98921aae5892810f239b794e6472732198670272 100644 (file)
@@ -167,7 +167,7 @@ static inline const char *cs_get_data_name(const struct conn_stream *cs)
 }
 
 /* shut read */
-static inline void cs_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
+static inline void cs_shutr(struct conn_stream *cs, enum co_shr_mode mode)
 {
        const struct mux_ops *mux;
 
@@ -178,11 +178,11 @@ static inline void cs_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
        mux = cs_conn_mux(cs);
        if (mux && mux->shutr)
                mux->shutr(cs, mode);
-       cs->endp->flags |= (mode == CS_SHR_DRAIN) ? CS_EP_SHRD : CS_EP_SHRR;
+       cs->endp->flags |= (mode == CO_SHR_DRAIN) ? CS_EP_SHRD : CS_EP_SHRR;
 }
 
 /* shut write */
-static inline void cs_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
+static inline void cs_shutw(struct conn_stream *cs, enum co_shw_mode mode)
 {
        const struct mux_ops *mux;
 
@@ -193,21 +193,21 @@ static inline void cs_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
        mux = cs_conn_mux(cs);
        if (mux && mux->shutw)
                mux->shutw(cs, mode);
-       cs->endp->flags |= (mode == CS_SHW_NORMAL) ? CS_EP_SHWN : CS_EP_SHWS;
+       cs->endp->flags |= (mode == CO_SHW_NORMAL) ? CS_EP_SHWN : CS_EP_SHWS;
 }
 
 /* completely close a conn_stream (but do not detach it) */
 static inline void cs_close(struct conn_stream *cs)
 {
-       cs_shutw(cs, CS_SHW_SILENT);
-       cs_shutr(cs, CS_SHR_RESET);
+       cs_shutw(cs, CO_SHW_SILENT);
+       cs_shutr(cs, CO_SHR_RESET);
 }
 
 /* completely close a conn_stream after draining possibly pending data (but do not detach it) */
 static inline void cs_drain_and_close(struct conn_stream *cs)
 {
-       cs_shutw(cs, CS_SHW_SILENT);
-       cs_shutr(cs, CS_SHR_DRAIN);
+       cs_shutw(cs, CO_SHW_SILENT);
+       cs_shutr(cs, CO_SHR_DRAIN);
 }
 
 /* sets CS_EP_ERROR or CS_EP_ERR_PENDING on the cs */
index c86311a60abd6b28429c05f860e59efcbb958339..644a3fd4a3bcad8af5769d2599faec28145d2c2e 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <haproxy/api-t.h>
 #include <haproxy/buf-t.h>
-#include <haproxy/conn_stream-t.h>
 #include <haproxy/obj_type-t.h>
 #include <haproxy/port_range-t.h>
 #include <haproxy/protocol-t.h>
@@ -253,6 +252,18 @@ enum {
        CO_SFL_STREAMER    = 0x0002,    /* Producer is continuously streaming data */
 };
 
+/* mux->shutr() modes */
+enum co_shr_mode {
+       CO_SHR_DRAIN        = 0,           /* read shutdown, drain any extra stuff */
+       CO_SHR_RESET        = 1,           /* read shutdown, reset any extra stuff */
+};
+
+/* mux->shutw() modes */
+enum co_shw_mode {
+       CO_SHW_NORMAL       = 0,           /* regular write shutdown */
+       CO_SHW_SILENT       = 1,           /* imminent close, don't notify peer */
+};
+
 /* known transport layers (for ease of lookup) */
 enum {
        XPRT_RAW = 0,
@@ -381,8 +392,8 @@ struct mux_ops {
        size_t (*snd_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to send data */
        int  (*rcv_pipe)(struct conn_stream *cs, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
        int  (*snd_pipe)(struct conn_stream *cs, struct pipe *pipe); /* send-to-pipe callback */
-       void (*shutr)(struct conn_stream *cs, enum cs_shr_mode);     /* shutr function */
-       void (*shutw)(struct conn_stream *cs, enum cs_shw_mode);     /* shutw function */
+       void (*shutr)(struct conn_stream *cs, enum co_shr_mode);     /* shutr function */
+       void (*shutw)(struct conn_stream *cs, enum co_shw_mode);     /* shutw function */
 
        int (*attach)(struct connection *conn, struct conn_stream *, struct session *sess); /* attach a conn_stream to an outgoing connection */
        const struct conn_stream *(*get_first_cs)(const struct connection *); /* retrieves any valid conn_stream from this connection */
index 0dbafcf43d27597917feabefbec3ebe8a09f3937..075320061329654be1fb30d963d517f57981425e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <haproxy/api-t.h>
 #include <haproxy/channel-t.h>
+#include <haproxy/conn_stream-t.h>
 #include <haproxy/dynbuf-t.h>
 #include <haproxy/filters-t.h>
 #include <haproxy/obj_type-t.h>
@@ -107,7 +108,6 @@ enum {
        STRM_ET_DATA_ABRT  = 0x0400,  /* data phase aborted by external cause */
 };
 
-struct conn_stream;
 struct hlua;
 struct proxy;
 struct pendconn;
index 6133c7e5479348cb812607c0ceb523dbee905fe4..d34b1c5ecc04077fdb62985a3b5a75e4a5b21caf 100644 (file)
@@ -3854,7 +3854,7 @@ struct task *fcgi_deferred_shut(struct task *t, void *ctx, unsigned int state)
 }
 
 /* shutr() called by the conn_stream (mux_ops.shutr) */
-static void fcgi_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
+static void fcgi_shutr(struct conn_stream *cs, enum co_shr_mode mode)
 {
        struct fcgi_strm *fstrm = __cs_mux(cs);
 
@@ -3865,7 +3865,7 @@ static void fcgi_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
 }
 
 /* shutw() called by the conn_stream (mux_ops.shutw) */
-static void fcgi_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
+static void fcgi_shutw(struct conn_stream *cs, enum co_shw_mode mode)
 {
        struct fcgi_strm *fstrm = __cs_mux(cs);
 
index 803cd8841a02ec0d481164096a45f3c9044ee7c6..bbdddf9a4e5bbcc26ce938fbef9383ed7ecf6579 100644 (file)
@@ -3447,7 +3447,7 @@ static void h1_detach(struct conn_stream *cs)
 }
 
 
-static void h1_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
+static void h1_shutr(struct conn_stream *cs, enum co_shr_mode mode)
 {
        struct h1s *h1s = __cs_mux(cs);
        struct h1c *h1c;
@@ -3485,12 +3485,12 @@ static void h1_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
                goto end;
 
        if (conn_xprt_ready(h1c->conn) && h1c->conn->xprt->shutr)
-               h1c->conn->xprt->shutr(h1c->conn, h1c->conn->xprt_ctx, (mode == CS_SHR_DRAIN));
+               h1c->conn->xprt->shutr(h1c->conn, h1c->conn->xprt_ctx, (mode == CO_SHR_DRAIN));
   end:
        TRACE_LEAVE(H1_EV_STRM_SHUT, h1c->conn, h1s);
 }
 
-static void h1_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
+static void h1_shutw(struct conn_stream *cs, enum co_shw_mode mode)
 {
        struct h1s *h1s = __cs_mux(cs);
        struct h1c *h1c;
@@ -3524,7 +3524,7 @@ static void h1_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
 
   do_shutw:
        h1c->flags |= H1C_F_ST_SHUTDOWN;
-       if (mode != CS_SHW_NORMAL)
+       if (mode != CO_SHW_NORMAL)
                h1c->flags |= H1C_F_ST_SILENT_SHUT;
 
        if (!b_data(&h1c->obuf))
index 4bd652e8ff1dba6566a7add4cae6f077dac4233c..b161278b5fed671b40608591f1e02088a5a7b38c 100644 (file)
@@ -4666,7 +4666,7 @@ struct task *h2_deferred_shut(struct task *t, void *ctx, unsigned int state)
 }
 
 /* shutr() called by the conn_stream (mux_ops.shutr) */
-static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
+static void h2_shutr(struct conn_stream *cs, enum co_shr_mode mode)
 {
        struct h2s *h2s = __cs_mux(cs);
 
@@ -4677,7 +4677,7 @@ static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
 }
 
 /* shutw() called by the conn_stream (mux_ops.shutw) */
-static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
+static void h2_shutw(struct conn_stream *cs, enum co_shw_mode mode)
 {
        struct h2s *h2s = __cs_mux(cs);
 
index 32f803fa276cbb54e0605b1746f68ca6ab4d9e66..2b1c30d6618e444bd7a520fe9321925f3350912e 100644 (file)
@@ -458,7 +458,7 @@ static int mux_pt_avail_streams(struct connection *conn)
        return 1 - mux_pt_used_streams(conn);
 }
 
-static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
+static void mux_pt_shutr(struct conn_stream *cs, enum co_shr_mode mode)
 {
        struct connection *conn = __cs_conn(cs);
 
@@ -469,8 +469,8 @@ static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
        cs->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
        if (conn_xprt_ready(conn) && conn->xprt->shutr)
                conn->xprt->shutr(conn, conn->xprt_ctx,
-                   (mode == CS_SHR_DRAIN));
-       else if (mode == CS_SHR_DRAIN)
+                   (mode == CO_SHR_DRAIN));
+       else if (mode == CO_SHR_DRAIN)
                conn_ctrl_drain(conn);
        if (cs->endp->flags & CS_EP_SHW)
                conn_full_close(conn);
@@ -478,7 +478,7 @@ static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
        TRACE_LEAVE(PT_EV_STRM_SHUT, conn, cs);
 }
 
-static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
+static void mux_pt_shutw(struct conn_stream *cs, enum co_shw_mode mode)
 {
        struct connection *conn = __cs_conn(cs);
 
@@ -488,9 +488,9 @@ static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
                return;
        if (conn_xprt_ready(conn) && conn->xprt->shutw)
                conn->xprt->shutw(conn, conn->xprt_ctx,
-                   (mode == CS_SHW_NORMAL));
+                   (mode == CO_SHW_NORMAL));
        if (!(cs->endp->flags & CS_EP_SHR))
-               conn_sock_shutw(conn, (mode == CS_SHW_NORMAL));
+               conn_sock_shutw(conn, (mode == CO_SHW_NORMAL));
        else
                conn_full_close(conn);
 
index ca7c616ec97fafc450ce3b5ca1ffa4ad83c478ed..139b6548c83aeb4b56f1751238aba8b13b53310d 100644 (file)
@@ -1065,7 +1065,7 @@ static void stream_int_shutw_conn(struct stream_interface *si)
                         * option abortonclose. No need for the TLS layer to try to
                         * emit a shutdown message.
                         */
-                       cs_shutw(cs, CS_SHW_SILENT);
+                       cs_shutw(cs, CO_SHW_SILENT);
                }
                else {
                        /* clean data-layer shutdown. This only happens on the
@@ -1074,7 +1074,7 @@ static void stream_int_shutw_conn(struct stream_interface *si)
                         * while option abortonclose is set. We want the TLS
                         * layer to try to signal it to the peer before we close.
                         */
-                       cs_shutw(cs, CS_SHW_NORMAL);
+                       cs_shutw(cs, CO_SHW_NORMAL);
 
                        if (!(ic->flags & (CF_SHUTR|CF_DONT_READ)))
                                return;
@@ -1569,7 +1569,7 @@ static void stream_int_read0(struct stream_interface *si)
        if (cs->flags & CS_FL_NOHALF) {
                /* we want to immediately forward this close to the write side */
                /* force flag on ssl to keep stream in cache */
-               cs_shutw(cs, CS_SHW_SILENT);
+               cs_shutw(cs, CO_SHW_SILENT);
                goto do_close;
        }