BUG/MEDIUM: mux-h1: Handle connection error after a synchronous send

Since commit d1480cc8 ("BUG/MEDIUM: stream-int: do not rely on the
connection error once established"), connection errors are not handled
anymore by the stream-connector once established. But it is a problem for
the H1 mux when an error occurred during a synchronous send in
h1_snd_buf(). Because in this case, the connction error is just missed. It
leads to a session leak until a timeout is reached (client or server).

To fix the bug, the connection flags are now checked in h1_snd_buf(). If
there is an error, it is reported to the stconn level by setting SF_FL_ERROR
flags. But only if there is no pending data in the input buffer.

This patch should solve the issue #1774. It must be backported as far as
2.2.
This commit is contained in:
Christopher Faulet 2022-07-08 15:20:31 +02:00
parent 52fc0cbaad
commit 372b38f935
1 changed files with 4 additions and 1 deletions

View File

@ -3729,6 +3729,9 @@ static size_t h1_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in
else else
TRACE_DEVEL("h1c obuf not allocated", H1_EV_STRM_SEND|H1_EV_H1S_BLK, h1c->conn, h1s); TRACE_DEVEL("h1c obuf not allocated", H1_EV_STRM_SEND|H1_EV_H1S_BLK, h1c->conn, h1s);
if ((h1c->conn->flags & (CO_FL_ERROR|CO_FL_SOCK_WR_SH)))
break;
if ((count - ret) > 0) if ((count - ret) > 0)
h1c->flags |= H1C_F_CO_MSG_MORE; h1c->flags |= H1C_F_CO_MSG_MORE;
@ -3740,7 +3743,7 @@ static size_t h1_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in
break; break;
} }
if (h1c->flags & H1C_F_ST_ERROR) { if (h1c->flags & H1C_F_ST_ERROR || ((h1c->conn->flags & CO_FL_ERROR) && !b_data(&h1c->ibuf))) {
se_fl_set(h1s->sd, SE_FL_ERROR); se_fl_set(h1s->sd, SE_FL_ERROR);
TRACE_ERROR("reporting error to the app-layer stream", H1_EV_STRM_SEND|H1_EV_H1S_ERR|H1_EV_STRM_ERR, h1c->conn, h1s); TRACE_ERROR("reporting error to the app-layer stream", H1_EV_STRM_SEND|H1_EV_H1S_ERR|H1_EV_STRM_ERR, h1c->conn, h1s);
} }