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 se_shut_mode); /* shutr function */
- void (*shutw)(struct stconn *sc, enum se_shut_mode); /* shutw function */
+ void (*shut)(struct stconn *sc, enum se_shut_mode); /* shutdown 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 */
return NULL;
}
-/* shutr() called by the stream connector (mux_ops.shutr) */
-static void fcgi_shutr(struct stconn *sc, enum se_shut_mode mode)
+static void fcgi_shut(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);
+ TRACE_ENTER(FCGI_EV_STRM_SHUT, fstrm->fconn->conn, fstrm);
+ if (mode & (SE_SHW_SILENT|SE_SHW_NORMAL))
+ fcgi_do_shutw(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 se_shut_mode mode)
-{
- struct fcgi_strm *fstrm = __sc_mux_strm(sc);
-
- TRACE_POINT(FCGI_EV_STRM_SHUT, fstrm->fconn->conn, fstrm);
- fcgi_do_shutw(fstrm);
+ TRACE_LEAVE(FCGI_EV_STRM_SHUT, fstrm->fconn->conn, fstrm);
}
/* Called from the upper layer, to subscribe <es> to events <event_type>. The
.snd_buf = fcgi_snd_buf,
.subscribe = fcgi_subscribe,
.unsubscribe = fcgi_unsubscribe,
- .shutr = fcgi_shutr,
- .shutw = fcgi_shutw,
+ .shut = fcgi_shut,
.ctl = fcgi_ctl,
.sctl = fcgi_sctl,
.show_fd = fcgi_show_fd,
TRACE_LEAVE(H1_EV_STRM_END);
}
-
-static void h1_shutr(struct stconn *sc, enum se_shut_mode mode)
-{
- struct h1s *h1s = __sc_mux_strm(sc);
- struct h1c *h1c;
-
- if (!h1s)
- return;
- h1c = h1s->h1c;
-
- TRACE_POINT(H1_EV_STRM_SHUT, h1c->conn, h1s, 0, (size_t[]){mode});
-}
-
-static void h1_shutw(struct stconn *sc, enum se_shut_mode mode)
+static void h1_shut(struct stconn *sc, enum se_shut_mode mode)
{
struct h1s *h1s = __sc_mux_strm(sc);
struct h1c *h1c;
- if (!h1s)
+ if (!h1s || !(mode & (SE_SHW_SILENT|SE_SHW_NORMAL)))
return;
h1c = h1s->h1c;
.resume_fastfwd = h1_resume_fastfwd,
.subscribe = h1_subscribe,
.unsubscribe = h1_unsubscribe,
- .shutr = h1_shutr,
- .shutw = h1_shutw,
+ .shut = h1_shut,
.show_fd = h1_show_fd,
.show_sd = h1_show_sd,
.ctl = h1_ctl,
.resume_fastfwd = h1_resume_fastfwd,
.subscribe = h1_subscribe,
.unsubscribe = h1_unsubscribe,
- .shutr = h1_shutr,
- .shutw = h1_shutw,
+ .shut = h1_shut,
.show_fd = h1_show_fd,
.show_sd = h1_show_sd,
.ctl = h1_ctl,
return t;
}
-/* shutr() called by the stream connector (mux_ops.shutr) */
-static void h2_shutr(struct stconn *sc, enum se_shut_mode mode)
+static void h2_shut(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 & (SE_SHW_SILENT|SE_SHW_NORMAL))
+ h2_do_shutw(h2s);
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 se_shut_mode mode)
-{
- struct h2s *h2s = __sc_mux_strm(sc);
-
- TRACE_ENTER(H2_EV_STRM_SHUT, h2s->h2c->conn, h2s);
- h2_do_shutw(h2s);
- TRACE_LEAVE(H2_EV_STRM_SHUT, h2s->h2c->conn, h2s);
-}
-
/* Decode the payload of a HEADERS frame and produce the HTX request or response
* depending on the connection's side. Returns a positive value on success, a
* negative value on failure, or 0 if it couldn't proceed. May report connection
.destroy = h2_destroy,
.avail_streams = h2_avail_streams,
.used_streams = h2_used_streams,
- .shutr = h2_shutr,
- .shutw = h2_shutw,
+ .shut = h2_shut,
.ctl = h2_ctl,
.sctl = h2_sctl,
.show_fd = h2_show_fd,
return 1 - mux_pt_used_streams(conn);
}
-static void mux_pt_shutr(struct stconn *sc, enum se_shut_mode mode)
+static void mux_pt_shut(struct stconn *sc, enum se_shut_mode mode)
{
struct connection *conn = __sc_conn(sc);
struct mux_pt_ctx *ctx = conn->ctx;
TRACE_ENTER(PT_EV_STRM_SHUT, conn, sc);
+ if (mode & (SE_SHW_SILENT|SE_SHW_NORMAL)) {
+ if (conn_xprt_ready(conn) && conn->xprt->shutw)
+ conn->xprt->shutw(conn, conn->xprt_ctx, (mode & SE_SHW_NORMAL));
+ if (conn->flags & CO_FL_SOCK_RD_SH)
+ conn_full_close(conn);
+ else
+ conn_sock_shutw(conn, (mode & SE_SHW_NORMAL));
+ }
- 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 & 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 se_shut_mode mode)
-{
- struct connection *conn = __sc_conn(sc);
-
- TRACE_ENTER(PT_EV_STRM_SHUT, conn, sc);
-
- if (conn_xprt_ready(conn) && conn->xprt->shutw)
- conn->xprt->shutw(conn, conn->xprt_ctx,
- (mode & SE_SHW_NORMAL));
- if (!(conn->flags & CO_FL_SOCK_RD_SH))
- conn_sock_shutw(conn, (mode & SE_SHW_NORMAL));
- else
- conn_full_close(conn);
+ if (mode & (SE_SHR_RESET|SE_SHR_DRAIN)) {
+ 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 & 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);
}
.destroy = mux_pt_destroy_meth,
.ctl = mux_pt_ctl,
.sctl = mux_pt_sctl,
- .shutr = mux_pt_shutr,
- .shutw = mux_pt_shutw,
+ .shut = mux_pt_shut,
.flags = MX_FL_NONE,
.name = "PASS",
};
.destroy = mux_pt_destroy_meth,
.ctl = mux_pt_ctl,
.sctl = mux_pt_sctl,
- .shutr = mux_pt_shutr,
- .shutw = mux_pt_shutw,
+ .shut = mux_pt_shut,
.flags = MX_FL_NONE|MX_FL_NO_UPG,
.name = "PASS",
};
return 1;
}
-static void qmux_strm_shutw(struct stconn *sc, enum se_shut_mode mode)
+static void qmux_strm_shut(struct stconn *sc, enum se_shut_mode mode)
{
struct qcs *qcs = __sc_mux_strm(sc);
struct qcc *qcc = qcs->qcc;
+ if (!(mode & (SE_SHW_SILENT|SE_SHW_NORMAL)))
+ return;
+
TRACE_ENTER(QMUX_EV_STRM_SHUT, qcc->conn, qcs);
/* Early closure reported if QC_SF_FIN_STREAM not yet set. */
.subscribe = qmux_strm_subscribe,
.unsubscribe = qmux_strm_unsubscribe,
.wake = qmux_wake,
- .shutw = qmux_strm_shutw,
+ .shut = qmux_strm_shut,
.sctl = qmux_sctl,
.show_sd = qmux_strm_show_sd,
.flags = MX_FL_HTX|MX_FL_NO_UPG|MX_FL_FRAMED,
{
if (se_fl_test(sedesc, SE_FL_T_MUX)) {
const struct mux_ops *mux = (sedesc->conn ? sedesc->conn->mux : NULL);
+ unsigned int flags = 0;
- if ((mode & (SE_SHW_SILENT|SE_SHW_NORMAL)) && !se_fl_test(sedesc, SE_FL_SHW)) {
- if (mux && mux->shutw)
- mux->shutw(sedesc->sc, mode);
- se_fl_set(sedesc, (mode & SE_SHW_NORMAL) ? SE_FL_SHWN : SE_FL_SHWS);
- }
+ if ((mode & (SE_SHW_SILENT|SE_SHW_NORMAL)) && !se_fl_test(sedesc, SE_FL_SHW))
+ flags |= (mode & SE_SHW_NORMAL) ? SE_FL_SHWN : SE_FL_SHWS;
+
+
+ if ((mode & (SE_SHR_RESET|SE_SHR_DRAIN)) && !se_fl_test(sedesc, SE_FL_SHR))
+ flags |= (mode & SE_SHR_DRAIN) ? SE_FL_SHRD : SE_FL_SHRR;
- if ((mode & (SE_SHR_RESET|SE_SHR_DRAIN)) && !se_fl_test(sedesc, SE_FL_SHR)) {
- if (mux && mux->shutr)
- mux->shutr(sedesc->sc, mode);
- se_fl_set(sedesc, (mode & SE_SHR_DRAIN) ? SE_FL_SHRD : SE_FL_SHRR);
+ if (flags) {
+ if (mux && mux->shut)
+ mux->shut(sedesc->sc, mode);
+ se_fl_set(sedesc, flags);
}
}
else if (se_fl_test(sedesc, SE_FL_T_APPLET)) {