mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
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.
This commit is contained in:
parent
e39a4dfdf0
commit
0797656ead
@ -24,6 +24,7 @@
|
|||||||
#define _HAPROXY_CONN_STREAM_T_H
|
#define _HAPROXY_CONN_STREAM_T_H
|
||||||
|
|
||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
|
#include <haproxy/connection-t.h>
|
||||||
|
|
||||||
struct stream_interface;
|
struct stream_interface;
|
||||||
|
|
||||||
@ -89,18 +90,6 @@ enum {
|
|||||||
CS_FL_INDEP_STR = 0x00000040, /* independent streams = don't update rex on write */
|
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
|
/* 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
|
* applications can rely on what the buffer reports while the conn stream is
|
||||||
* performing some retries (eg: connection error). Some states are transient and
|
* performing some retries (eg: connection error). Some states are transient and
|
||||||
|
@ -167,7 +167,7 @@ static inline const char *cs_get_data_name(const struct conn_stream *cs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* shut read */
|
/* 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;
|
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);
|
mux = cs_conn_mux(cs);
|
||||||
if (mux && mux->shutr)
|
if (mux && mux->shutr)
|
||||||
mux->shutr(cs, mode);
|
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 */
|
/* 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;
|
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);
|
mux = cs_conn_mux(cs);
|
||||||
if (mux && mux->shutw)
|
if (mux && mux->shutw)
|
||||||
mux->shutw(cs, mode);
|
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) */
|
/* completely close a conn_stream (but do not detach it) */
|
||||||
static inline void cs_close(struct conn_stream *cs)
|
static inline void cs_close(struct conn_stream *cs)
|
||||||
{
|
{
|
||||||
cs_shutw(cs, CS_SHW_SILENT);
|
cs_shutw(cs, CO_SHW_SILENT);
|
||||||
cs_shutr(cs, CS_SHR_RESET);
|
cs_shutr(cs, CO_SHR_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* completely close a conn_stream after draining possibly pending data (but do not detach it) */
|
/* 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)
|
static inline void cs_drain_and_close(struct conn_stream *cs)
|
||||||
{
|
{
|
||||||
cs_shutw(cs, CS_SHW_SILENT);
|
cs_shutw(cs, CO_SHW_SILENT);
|
||||||
cs_shutr(cs, CS_SHR_DRAIN);
|
cs_shutr(cs, CO_SHR_DRAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sets CS_EP_ERROR or CS_EP_ERR_PENDING on the cs */
|
/* sets CS_EP_ERROR or CS_EP_ERR_PENDING on the cs */
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include <haproxy/api-t.h>
|
#include <haproxy/api-t.h>
|
||||||
#include <haproxy/buf-t.h>
|
#include <haproxy/buf-t.h>
|
||||||
#include <haproxy/conn_stream-t.h>
|
|
||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
#include <haproxy/port_range-t.h>
|
#include <haproxy/port_range-t.h>
|
||||||
#include <haproxy/protocol-t.h>
|
#include <haproxy/protocol-t.h>
|
||||||
@ -253,6 +252,18 @@ enum {
|
|||||||
CO_SFL_STREAMER = 0x0002, /* Producer is continuously streaming data */
|
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) */
|
/* known transport layers (for ease of lookup) */
|
||||||
enum {
|
enum {
|
||||||
XPRT_RAW = 0,
|
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 */
|
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 (*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 */
|
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 (*shutr)(struct conn_stream *cs, enum co_shr_mode); /* shutr function */
|
||||||
void (*shutw)(struct conn_stream *cs, enum cs_shw_mode); /* shutw 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 */
|
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 */
|
const struct conn_stream *(*get_first_cs)(const struct connection *); /* retrieves any valid conn_stream from this connection */
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <haproxy/api-t.h>
|
#include <haproxy/api-t.h>
|
||||||
#include <haproxy/channel-t.h>
|
#include <haproxy/channel-t.h>
|
||||||
|
#include <haproxy/conn_stream-t.h>
|
||||||
#include <haproxy/dynbuf-t.h>
|
#include <haproxy/dynbuf-t.h>
|
||||||
#include <haproxy/filters-t.h>
|
#include <haproxy/filters-t.h>
|
||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
@ -107,7 +108,6 @@ enum {
|
|||||||
STRM_ET_DATA_ABRT = 0x0400, /* data phase aborted by external cause */
|
STRM_ET_DATA_ABRT = 0x0400, /* data phase aborted by external cause */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct conn_stream;
|
|
||||||
struct hlua;
|
struct hlua;
|
||||||
struct proxy;
|
struct proxy;
|
||||||
struct pendconn;
|
struct pendconn;
|
||||||
|
@ -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) */
|
/* 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);
|
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) */
|
/* 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);
|
struct fcgi_strm *fstrm = __cs_mux(cs);
|
||||||
|
|
||||||
|
@ -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 h1s *h1s = __cs_mux(cs);
|
||||||
struct h1c *h1c;
|
struct h1c *h1c;
|
||||||
@ -3485,12 +3485,12 @@ static void h1_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
|
|||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (conn_xprt_ready(h1c->conn) && h1c->conn->xprt->shutr)
|
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:
|
end:
|
||||||
TRACE_LEAVE(H1_EV_STRM_SHUT, h1c->conn, h1s);
|
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 h1s *h1s = __cs_mux(cs);
|
||||||
struct h1c *h1c;
|
struct h1c *h1c;
|
||||||
@ -3524,7 +3524,7 @@ static void h1_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
|
|||||||
|
|
||||||
do_shutw:
|
do_shutw:
|
||||||
h1c->flags |= H1C_F_ST_SHUTDOWN;
|
h1c->flags |= H1C_F_ST_SHUTDOWN;
|
||||||
if (mode != CS_SHW_NORMAL)
|
if (mode != CO_SHW_NORMAL)
|
||||||
h1c->flags |= H1C_F_ST_SILENT_SHUT;
|
h1c->flags |= H1C_F_ST_SILENT_SHUT;
|
||||||
|
|
||||||
if (!b_data(&h1c->obuf))
|
if (!b_data(&h1c->obuf))
|
||||||
|
@ -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) */
|
/* 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);
|
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) */
|
/* 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);
|
struct h2s *h2s = __cs_mux(cs);
|
||||||
|
|
||||||
|
12
src/mux_pt.c
12
src/mux_pt.c
@ -458,7 +458,7 @@ static int mux_pt_avail_streams(struct connection *conn)
|
|||||||
return 1 - mux_pt_used_streams(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);
|
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);
|
cs->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM);
|
||||||
if (conn_xprt_ready(conn) && conn->xprt->shutr)
|
if (conn_xprt_ready(conn) && conn->xprt->shutr)
|
||||||
conn->xprt->shutr(conn, conn->xprt_ctx,
|
conn->xprt->shutr(conn, conn->xprt_ctx,
|
||||||
(mode == CS_SHR_DRAIN));
|
(mode == CO_SHR_DRAIN));
|
||||||
else if (mode == CS_SHR_DRAIN)
|
else if (mode == CO_SHR_DRAIN)
|
||||||
conn_ctrl_drain(conn);
|
conn_ctrl_drain(conn);
|
||||||
if (cs->endp->flags & CS_EP_SHW)
|
if (cs->endp->flags & CS_EP_SHW)
|
||||||
conn_full_close(conn);
|
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);
|
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);
|
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;
|
return;
|
||||||
if (conn_xprt_ready(conn) && conn->xprt->shutw)
|
if (conn_xprt_ready(conn) && conn->xprt->shutw)
|
||||||
conn->xprt->shutw(conn, conn->xprt_ctx,
|
conn->xprt->shutw(conn, conn->xprt_ctx,
|
||||||
(mode == CS_SHW_NORMAL));
|
(mode == CO_SHW_NORMAL));
|
||||||
if (!(cs->endp->flags & CS_EP_SHR))
|
if (!(cs->endp->flags & CS_EP_SHR))
|
||||||
conn_sock_shutw(conn, (mode == CS_SHW_NORMAL));
|
conn_sock_shutw(conn, (mode == CO_SHW_NORMAL));
|
||||||
else
|
else
|
||||||
conn_full_close(conn);
|
conn_full_close(conn);
|
||||||
|
|
||||||
|
@ -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
|
* option abortonclose. No need for the TLS layer to try to
|
||||||
* emit a shutdown message.
|
* emit a shutdown message.
|
||||||
*/
|
*/
|
||||||
cs_shutw(cs, CS_SHW_SILENT);
|
cs_shutw(cs, CO_SHW_SILENT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* clean data-layer shutdown. This only happens on the
|
/* 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
|
* while option abortonclose is set. We want the TLS
|
||||||
* layer to try to signal it to the peer before we close.
|
* 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)))
|
if (!(ic->flags & (CF_SHUTR|CF_DONT_READ)))
|
||||||
return;
|
return;
|
||||||
@ -1569,7 +1569,7 @@ static void stream_int_read0(struct stream_interface *si)
|
|||||||
if (cs->flags & CS_FL_NOHALF) {
|
if (cs->flags & CS_FL_NOHALF) {
|
||||||
/* we want to immediately forward this close to the write side */
|
/* we want to immediately forward this close to the write side */
|
||||||
/* force flag on ssl to keep stream in cache */
|
/* force flag on ssl to keep stream in cache */
|
||||||
cs_shutw(cs, CS_SHW_SILENT);
|
cs_shutw(cs, CO_SHW_SILENT);
|
||||||
goto do_close;
|
goto do_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user