Skip to content

Commit 4ef5251

Browse files
committed
BUG/MEDIUM: mux-h2: Set ES flag when necessary on 0-copy data forwarding
When DATA frames are sent via the 0-copy data forwarding, we must take care to set the ES flag on the last DATA frame. It should be performed in h2_done_ff() when IOBUF_FL_EOI flag was set by the producer. This flag is here to know when the producer has reached the end of input. When this happens, the h2s state is also updated. It is switched to "half-closed local" or "closed" state depending on its previous state. It is mainly an issue on uploads because the server may be blocked waiting for the end of the request. A workaround is to disable the 0-copy forwarding support the the H2 by setting "tune.h2.zero-copy-fwd-send" directive to off in your global section. This patch should fix the issue #2665. It must be backported as far as 2.9.
1 parent 0d142e0 commit 4ef5251

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/mux_h2.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7372,6 +7372,7 @@ static size_t h2_done_ff(struct stconn *sc)
73727372
struct buffer *mbuf;
73737373
char *head;
73747374
size_t total = 0;
7375+
int es_now = 0;
73757376

73767377
TRACE_ENTER(H2_EV_H2S_SEND|H2_EV_STRM_SEND, h2s->h2c->conn, h2s);
73777378

@@ -7380,8 +7381,10 @@ static size_t h2_done_ff(struct stconn *sc)
73807381
goto end;
73817382
head = b_peek(mbuf, b_data(mbuf) - sd->iobuf.data);
73827383

7383-
if (sd->iobuf.flags & IOBUF_FL_EOI)
7384+
if (sd->iobuf.flags & IOBUF_FL_EOI) {
7385+
es_now = 1;
73847386
h2s->flags &= ~H2_SF_MORE_HTX_DATA;
7387+
}
73857388

73867389
if (!(sd->iobuf.flags & IOBUF_FL_FF_BLOCKED) &&
73877390
!(h2s->flags & H2_SF_BLK_SFCTL) &&
@@ -7398,12 +7401,24 @@ static size_t h2_done_ff(struct stconn *sc)
73987401
*/
73997402
total = sd->iobuf.data;
74007403
h2_set_frame_size(head, total);
7404+
if (es_now)
7405+
head[4] |= H2_F_DATA_END_STREAM;
74017406
b_add(mbuf, 9);
74027407
h2s->sws -= total;
74037408
h2c->mws -= total;
74047409
if (h2_send(h2s->h2c))
74057410
tasklet_wakeup(h2s->h2c->wait_event.tasklet);
74067411

7412+
if (es_now) {
7413+
if (h2s->st == H2_SS_OPEN)
7414+
h2s->st = H2_SS_HLOC;
7415+
else
7416+
h2s_close(h2s);
7417+
7418+
h2s->flags |= H2_SF_ES_SENT;
7419+
TRACE_PROTO("ES flag set on outgoing frame", H2_EV_TX_FRAME|H2_EV_TX_DATA|H2_EV_TX_EOI, h2c->conn, h2s);
7420+
}
7421+
74077422
end:
74087423
sd->iobuf.buf = NULL;
74097424
sd->iobuf.offset = 0;

0 commit comments

Comments
 (0)