When a NOOP block carrying the EOM flag was processed by h2_snd_buf(), an
empty DATA frame with the ES flag was emitted to report the end of the
message. But if this frame could not be emitted, because the output buffer
was full or could not be allocated, the NOOP block was removed anyway and
counted as sent. So the end of the message was lost and the END_STREAM was
never sent. This could happen when the END_STREAM was received in a
separate empty DATA frame (or a standalone FIN for H3) while the H2
connection was congested. A server waiting for the end of the request could
then wait until a timeout. On the client side, the END_STREAM was only sent
on the stream shutdown.
Now, the NOOP block is kept when the empty DATA frame cannot be emitted.
The stream is blocked, like for other blocks, and it will be retried when
some room is made in the output buffer.
This patch must be backported to 3.5.
if (blk->flags & HTX_BLK_FL_EOM) {
h2s->flags &= ~H2_SF_MORE_HTX_DATA;
if (!(h2s->flags & H2_SF_BODY_TUNNEL)) {
- if (h2_send_empty_data_es(h2s) > 0) {
- if (h2s->st == H2_SS_OPEN)
- h2s->st = H2_SS_HLOC;
- else
- h2s_close(h2s);
- }
+ /* If the empty DATA frame cannot be
+ * emitted (no room or error), the
+ * NOOP block must be kept to not
+ * lose the end of the message.
+ */
+ if (h2_send_empty_data_es(h2s) <= 0)
+ goto done;
+ if (h2s->st == H2_SS_OPEN)
+ h2s->st = H2_SS_HLOC;
+ else
+ h2s_close(h2s);
}
}
htx_remove_blk(htx, blk);