#include <haproxy/port_range-t.h>
#include <haproxy/protocol-t.h>
#include <haproxy/show_flags-t.h>
+#include <haproxy/stconn-t.h>
#include <haproxy/task-t.h>
#include <haproxy/thread-t.h>
CO_SFL_LAST_DATA = 0x0003, /* Sent data are the last ones, shutdown is pending */
};
-/* 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,
size_t (*done_fastfwd)(struct stconn *sc); /* Callback to terminate fast data forwarding */
int (*fastfwd)(struct stconn *sc, unsigned int count, unsigned int flags); /* Callback to init fast data forwarding */
int (*resume_fastfwd)(struct stconn *sc, unsigned int flags); /* Callback to resume fast data forwarding */
- void (*shutr)(struct stconn *sc, enum co_shr_mode); /* shutr function */
- void (*shutw)(struct stconn *sc, enum co_shw_mode); /* shutw function */
+ void (*shutr)(struct stconn *sc, enum se_shut_mode); /* shutr function */
+ void (*shutw)(struct stconn *sc, enum se_shut_mode); /* shutw function */
int (*attach)(struct connection *conn, struct sedesc *, struct session *sess); /* attach a stconn to an outgoing connection */
struct stconn *(*get_first_sc)(const struct connection *); /* retrieves any valid stconn from this connection */
#include <haproxy/connection-t.h>
#include <haproxy/pipe-t.h>
#include <haproxy/show_flags-t.h>
+#include <haproxy/task-t.h>
#include <haproxy/xref-t.h>
enum iobuf_flags {
SE_FL_APPLET_NEED_CONN = 0x80000000, /* applet is waiting for the other side to (fail to) connect */
};
+/* Shutdown modes */
+enum se_shut_mode {
+ SE_SHR_DRAIN = 0x00000001, /* read shutdown, drain any extra stuff */
+ SE_SHR_RESET = 0x00000002, /* read shutdown, reset any extra stuff */
+ SE_SHW_NORMAL = 0x00000004, /* regular write shutdown */
+ SE_SHW_SILENT = 0x00000008, /* imminent close, don't notify peer */
+};
+
/* This function is used to report flags in debugging tools. Please reflect
* below any single-bit flag addition above in the same order via the
* __APPEND_FLAG macro. The new end of the buffer is returned.
}
/* shut read */
-static inline void sc_conn_shutr(struct stconn *sc, enum co_shr_mode mode)
+static inline void sc_conn_shutr(struct stconn *sc, enum se_shut_mode mode)
{
const struct mux_ops *mux;
mux = sc_mux_ops(sc);
if (mux && mux->shutr)
mux->shutr(sc, mode);
- sc_ep_set(sc, (mode == CO_SHR_DRAIN) ? SE_FL_SHRD : SE_FL_SHRR);
+ sc_ep_set(sc, (mode & SE_SHR_DRAIN) ? SE_FL_SHRD : SE_FL_SHRR);
}
/* shut write */
-static inline void sc_conn_shutw(struct stconn *sc, enum co_shw_mode mode)
+static inline void sc_conn_shutw(struct stconn *sc, enum se_shut_mode mode)
{
const struct mux_ops *mux;
mux = sc_mux_ops(sc);
if (mux && mux->shutw)
mux->shutw(sc, mode);
- sc_ep_set(sc, (mode == CO_SHW_NORMAL) ? SE_FL_SHWN : SE_FL_SHWS);
+ sc_ep_set(sc, (mode & SE_SHW_NORMAL) ? SE_FL_SHWN : SE_FL_SHWS);
}
/* completely close a stream connector (but do not detach it) */
static inline void sc_conn_shut(struct stconn *sc)
{
- sc_conn_shutw(sc, CO_SHW_SILENT);
- sc_conn_shutr(sc, CO_SHR_RESET);
+ sc_conn_shutw(sc, SE_SHW_SILENT);
+ sc_conn_shutr(sc, SE_SHR_RESET);
}
/* completely close a stream connector after draining possibly pending data (but do not detach it) */
static inline void sc_conn_drain_and_shut(struct stconn *sc)
{
- sc_conn_shutw(sc, CO_SHW_SILENT);
- sc_conn_shutr(sc, CO_SHR_DRAIN);
+ sc_conn_shutw(sc, SE_SHW_SILENT);
+ sc_conn_shutr(sc, SE_SHR_DRAIN);
}
/* Returns non-zero if the stream connector's Rx path is blocked because of
}
/* shutr() called by the stream connector (mux_ops.shutr) */
-static void fcgi_shutr(struct stconn *sc, enum co_shr_mode mode)
+static void fcgi_shutr(struct stconn *sc, enum se_shut_mode mode)
{
struct fcgi_strm *fstrm = __sc_mux_strm(sc);
TRACE_POINT(FCGI_EV_STRM_SHUT, fstrm->fconn->conn, fstrm);
- if (!mode)
- return;
- fcgi_do_shutr(fstrm);
+ if (mode & SE_SHR_RESET)
+ fcgi_do_shutr(fstrm);
}
/* shutw() called by the stream connector (mux_ops.shutw) */
-static void fcgi_shutw(struct stconn *sc, enum co_shw_mode mode)
+static void fcgi_shutw(struct stconn *sc, enum se_shut_mode mode)
{
struct fcgi_strm *fstrm = __sc_mux_strm(sc);
}
-static void h1_shutr(struct stconn *sc, enum co_shr_mode mode)
+static void h1_shutr(struct stconn *sc, enum se_shut_mode mode)
{
struct h1s *h1s = __sc_mux_strm(sc);
struct h1c *h1c;
TRACE_POINT(H1_EV_STRM_SHUT, h1c->conn, h1s, 0, (size_t[]){mode});
}
-static void h1_shutw(struct stconn *sc, enum co_shw_mode mode)
+static void h1_shutw(struct stconn *sc, enum se_shut_mode mode)
{
struct h1s *h1s = __sc_mux_strm(sc);
struct h1c *h1c;
do_shutw:
h1_close(h1c);
- if (mode != CO_SHW_NORMAL)
+ if (mode & SE_SHW_NORMAL)
h1c->flags |= H1C_F_SILENT_SHUT;
if (!b_data(&h1c->obuf))
}
/* shutr() called by the stream connector (mux_ops.shutr) */
-static void h2_shutr(struct stconn *sc, enum co_shr_mode mode)
+static void h2_shutr(struct stconn *sc, enum se_shut_mode mode)
{
struct h2s *h2s = __sc_mux_strm(sc);
TRACE_ENTER(H2_EV_STRM_SHUT, h2s->h2c->conn, h2s);
- if (mode)
+ if (mode & SE_SHR_RESET)
h2_do_shutr(h2s);
TRACE_LEAVE(H2_EV_STRM_SHUT, h2s->h2c->conn, h2s);
}
/* shutw() called by the stream connector (mux_ops.shutw) */
-static void h2_shutw(struct stconn *sc, enum co_shw_mode mode)
+static void h2_shutw(struct stconn *sc, enum se_shut_mode mode)
{
struct h2s *h2s = __sc_mux_strm(sc);
return 1 - mux_pt_used_streams(conn);
}
-static void mux_pt_shutr(struct stconn *sc, enum co_shr_mode mode)
+static void mux_pt_shutr(struct stconn *sc, enum se_shut_mode mode)
{
struct connection *conn = __sc_conn(sc);
struct mux_pt_ctx *ctx = conn->ctx;
se_fl_clr(ctx->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
if (conn_xprt_ready(conn) && conn->xprt->shutr)
conn->xprt->shutr(conn, conn->xprt_ctx,
- (mode == CO_SHR_DRAIN));
- else if (mode == CO_SHR_DRAIN)
+ (mode & SE_SHR_DRAIN));
+ else if (mode & SE_SHR_DRAIN)
conn_ctrl_drain(conn);
if (conn->flags & CO_FL_SOCK_WR_SH)
conn_full_close(conn);
TRACE_LEAVE(PT_EV_STRM_SHUT, conn, sc);
}
-static void mux_pt_shutw(struct stconn *sc, enum co_shw_mode mode)
+static void mux_pt_shutw(struct stconn *sc, enum se_shut_mode mode)
{
struct connection *conn = __sc_conn(sc);
if (conn_xprt_ready(conn) && conn->xprt->shutw)
conn->xprt->shutw(conn, conn->xprt_ctx,
- (mode == CO_SHW_NORMAL));
+ (mode & SE_SHW_NORMAL));
if (!(conn->flags & CO_FL_SOCK_RD_SH))
- conn_sock_shutw(conn, (mode == CO_SHW_NORMAL));
+ conn_sock_shutw(conn, (mode & SE_SHW_NORMAL));
else
conn_full_close(conn);
return 1;
}
-static void qmux_strm_shutw(struct stconn *sc, enum co_shw_mode mode)
+static void qmux_strm_shutw(struct stconn *sc, enum se_shut_mode mode)
{
struct qcs *qcs = __sc_mux_strm(sc);
struct qcc *qcc = qcs->qcc;
* option abortonclose. No need for the TLS layer to try to
* emit a shutdown message.
*/
- sc_conn_shutw(sc, CO_SHW_SILENT);
+ sc_conn_shutw(sc, SE_SHW_SILENT);
}
else {
/* clean data-layer shutdown. This only happens on the
* while option abortonclose is set. We want the TLS
* layer to try to signal it to the peer before we close.
*/
- sc_conn_shutw(sc, CO_SHW_NORMAL);
+ sc_conn_shutw(sc, SE_SHW_NORMAL);
if (!(sc->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) && !(ic->flags & CF_DONT_READ))
return;
if (sc_cond_forward_shut(sc)) {
/* we want to immediately forward this close to the write side */
/* force flag on ssl to keep stream in cache */
- sc_conn_shutw(sc, CO_SHW_SILENT);
+ sc_conn_shutw(sc, SE_SHW_SILENT);
goto do_close;
}