From 0797656ead86aa636c94cc4041cafd1b78640933 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 31 Mar 2022 11:05:05 +0200 Subject: [PATCH] MINOR: conn-stream/connection: Move SHR/SHW modes in the connection scope 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 | 13 +------------ include/haproxy/conn_stream.h | 16 ++++++++-------- include/haproxy/connection-t.h | 17 ++++++++++++++--- include/haproxy/stream-t.h | 2 +- src/mux_fcgi.c | 4 ++-- src/mux_h1.c | 8 ++++---- src/mux_h2.c | 4 ++-- src/mux_pt.c | 12 ++++++------ src/stream_interface.c | 6 +++--- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index fb0aa503d..a1e35389f 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -24,6 +24,7 @@ #define _HAPROXY_CONN_STREAM_T_H #include +#include 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 diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index aa708c75a..98921aae5 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -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 */ diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index c86311a60..644a3fd4a 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -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 */ diff --git a/include/haproxy/stream-t.h b/include/haproxy/stream-t.h index 0dbafcf43..075320061 100644 --- a/include/haproxy/stream-t.h +++ b/include/haproxy/stream-t.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -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; diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 6133c7e54..d34b1c5ec 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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); diff --git a/src/mux_h1.c b/src/mux_h1.c index 803cd8841..bbdddf9a4 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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)) diff --git a/src/mux_h2.c b/src/mux_h2.c index 4bd652e8f..b161278b5 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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); diff --git a/src/mux_pt.c b/src/mux_pt.c index 32f803fa2..2b1c30d66 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -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); diff --git a/src/stream_interface.c b/src/stream_interface.c index ca7c616ec..139b6548c 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -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; }