From: Christopher Faulet Date: Mon, 20 Mar 2023 07:25:38 +0000 (+0100) Subject: MINOR: mux-pt: Report end-of-input with the end-of-stream after a read X-Git-Tag: v2.8-dev7~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=872b01c984f77ced43afc41352ed91e1f1d4ec77;p=thirdparty%2Fhaproxy.git MINOR: mux-pt: Report end-of-input with the end-of-stream after a read In the PT multiplexer, the end of stream is also the end of input. Thus we must report EOI to the stream-endpoint descriptor when the EOS is reported. For now, it is a bit useless but it will be important to disginguish an shutdown to an error to an abort. To be sure to not report an EOI on an error, the errors are now handled first. --- diff --git a/src/mux_pt.c b/src/mux_pt.c index 4895c17804..f7a7292899 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -527,16 +527,18 @@ static size_t mux_pt_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count } b_realign_if_empty(buf); ret = conn->xprt->rcv_buf(conn, conn->xprt_ctx, buf, count, flags); - if (conn_xprt_read0_pending(conn)) { - se_fl_clr(ctx->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); - se_fl_set(ctx->sd, SE_FL_EOS); - TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, sc); - } if (conn->flags & CO_FL_ERROR) { se_fl_clr(ctx->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); + if (conn_xprt_read0_pending(conn)) + se_fl_set(ctx->sd, SE_FL_EOS); se_fl_set(ctx->sd, SE_FL_ERROR); TRACE_DEVEL("error on connection", PT_EV_RX_DATA|PT_EV_CONN_ERR, conn, sc); } + else if (conn_xprt_read0_pending(conn)) { + se_fl_clr(ctx->sd, SE_FL_RCV_MORE | SE_FL_WANT_ROOM); + se_fl_set(ctx->sd, (SE_FL_EOI|SE_FL_EOS)); + TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, sc); + } end: TRACE_LEAVE(PT_EV_RX_DATA, conn, sc, buf, (size_t[]){ret}); return ret; @@ -603,14 +605,16 @@ static int mux_pt_rcv_pipe(struct stconn *sc, struct pipe *pipe, unsigned int co TRACE_ENTER(PT_EV_RX_DATA, conn, sc, 0, (size_t[]){count}); ret = conn->xprt->rcv_pipe(conn, conn->xprt_ctx, pipe, count); - if (conn_xprt_read0_pending(conn)) { - se_fl_set(ctx->sd, SE_FL_EOS); - TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, sc); - } if (conn->flags & CO_FL_ERROR) { + if (conn_xprt_read0_pending(conn)) + se_fl_set(ctx->sd, SE_FL_EOS); se_fl_set(ctx->sd, SE_FL_ERROR); TRACE_DEVEL("error on connection", PT_EV_RX_DATA|PT_EV_CONN_ERR, conn, sc); } + else if (conn_xprt_read0_pending(conn)) { + se_fl_set(ctx->sd, (SE_FL_EOS|SE_FL_EOI)); + TRACE_DEVEL("read0 on connection", PT_EV_RX_DATA, conn, sc); + } TRACE_LEAVE(PT_EV_RX_DATA, conn, sc, 0, (size_t[]){ret}); return (ret);