mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 23:22:09 +00:00
MINOR: conn_stream: modify cs_shut{r,w} API to pass the desired mode
Now we can specify how we want to shutdown (drain vs reset, and normal vs silent), and this propagates to the mux then the transport layer.
This commit is contained in:
parent
79dadb5335
commit
ecdb3fe9f4
@ -537,45 +537,28 @@ static inline void conn_xprt_shutw_hard(struct connection *c)
|
||||
c->xprt->shutw(c, 0);
|
||||
}
|
||||
|
||||
/* shut read after draining possibly pending data */
|
||||
static inline void cs_shutr(struct conn_stream *cs)
|
||||
/* shut read */
|
||||
static inline void cs_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
|
||||
{
|
||||
__cs_stop_recv(cs);
|
||||
|
||||
/* clean data-layer shutdown */
|
||||
if (cs->conn->mux && cs->conn->mux->shutr)
|
||||
cs->conn->mux->shutr(cs, 1);
|
||||
cs->conn->mux->shutr(cs, mode);
|
||||
cs->flags |= (mode == CS_SHR_DRAIN) ? CS_FL_SHRD : CS_FL_SHRR;
|
||||
}
|
||||
|
||||
/* shut read after disabling lingering */
|
||||
static inline void cs_shutr_hard(struct conn_stream *cs)
|
||||
{
|
||||
__cs_stop_recv(cs);
|
||||
|
||||
/* clean data-layer shutdown */
|
||||
if (cs->conn->mux && cs->conn->mux->shutr)
|
||||
cs->conn->mux->shutr(cs, 0);
|
||||
}
|
||||
|
||||
static inline void cs_shutw(struct conn_stream *cs)
|
||||
/* shut write */
|
||||
static inline void cs_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
|
||||
{
|
||||
__cs_stop_send(cs);
|
||||
|
||||
/* clean data-layer shutdown */
|
||||
if (cs->conn->mux && cs->conn->mux->shutw)
|
||||
cs->conn->mux->shutw(cs, 1);
|
||||
cs->conn->mux->shutw(cs, mode);
|
||||
cs->flags |= (mode == CS_SHW_NORMAL) ? CS_FL_SHWN : CS_FL_SHWS;
|
||||
}
|
||||
|
||||
static inline void cs_shutw_hard(struct conn_stream *cs)
|
||||
{
|
||||
__cs_stop_send(cs);
|
||||
|
||||
/* unclean data-layer shutdown */
|
||||
if (cs->conn->mux && cs->conn->mux->shutw)
|
||||
cs->conn->mux->shutw(cs, 0);
|
||||
}
|
||||
|
||||
|
||||
/* detect sock->data read0 transition */
|
||||
static inline int conn_xprt_read0_pending(struct connection *c)
|
||||
{
|
||||
|
@ -292,8 +292,8 @@ struct mux_ops {
|
||||
int (*snd_buf)(struct conn_stream *cs, struct buffer *buf, 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, int clean); /* shutr function */
|
||||
void (*shutw)(struct conn_stream *cs, int clean); /* shutw function */
|
||||
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 (*release)(struct connection *conn); /* release all resources allocated by the mux */
|
||||
struct conn_stream *(*attach)(struct connection *); /* Create and attach a conn_stream to an outgoing connection */
|
||||
|
@ -1344,7 +1344,7 @@ static void event_srv_chk_r(struct conn_stream *cs)
|
||||
* drain pending data.
|
||||
*/
|
||||
__cs_stop_both(cs);
|
||||
cs_shutw(cs);
|
||||
cs_shutw(cs, CS_SHW_NORMAL);
|
||||
|
||||
/* OK, let's not stay here forever */
|
||||
if (check->result == CHK_RES_FAILED)
|
||||
|
@ -120,16 +120,16 @@ static void mux_pt_detach(struct conn_stream *cs)
|
||||
{
|
||||
}
|
||||
|
||||
static void mux_pt_shutr(struct conn_stream *cs, int clean)
|
||||
static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
|
||||
{
|
||||
if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutr)
|
||||
cs->conn->xprt->shutr(cs->conn, clean);
|
||||
cs->conn->xprt->shutr(cs->conn, (mode == CS_SHR_DRAIN));
|
||||
}
|
||||
|
||||
static void mux_pt_shutw(struct conn_stream *cs, int clean)
|
||||
static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
|
||||
{
|
||||
if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutw)
|
||||
cs->conn->xprt->shutw(cs->conn, clean);
|
||||
cs->conn->xprt->shutw(cs->conn, (mode == CS_SHW_NORMAL));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -880,7 +880,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_hard(cs);
|
||||
cs_shutw(cs, CS_SHW_SILENT);
|
||||
}
|
||||
else {
|
||||
/* clean data-layer shutdown. This only happens on the
|
||||
@ -889,7 +889,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_shutw(cs, CS_SHW_NORMAL);
|
||||
|
||||
/* If the stream interface is configured to disable half-open
|
||||
* connections, we'll skip the shutdown(), but only if the
|
||||
@ -1358,7 +1358,7 @@ void stream_sock_read0(struct stream_interface *si)
|
||||
if (si->flags & SI_FL_NOHALF) {
|
||||
/* we want to immediately forward this close to the write side */
|
||||
/* force flag on ssl to keep stream in cache */
|
||||
cs_shutw_hard(cs);
|
||||
cs_shutw(cs, CS_SHW_SILENT);
|
||||
goto do_close;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user