Previous commit fixes encoding of several following HTTP response
message when interim status codes are first reported. However,
h3_resp_headers_send() still was unable to interrupt encoding if output
buffer room was not sufficient. This case may be likely because small
buffers are used for headers encoding.
This commit fixes this situation. If output buffer is not empty prior to
response encoding, this means that a previous interim response message
was already encoded before. In this case, and if remaining space is not
sufficient, use buffer release mechanism : this allows to restart
response encoding by using a newer buffer. This process has already been
used for DATA and trailers encoding.
This must be backported up to 2.6. However, note that buffer release
mechanism is not present for version 2.8 and lower. In this case, qcs
flag QC_SF_BLK_MROOM should be enough as a replacement.
(cherry picked from commit
d59bdfb8ec5b5af284672af8a89bf0d1662d8efd)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit
aa92894f3ca042653f6bb568997bd7b548e2be55)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
return ret;
err_full:
+ if (b_data(res)) {
+ /* Output buffer already contains data : this may happens after
+ * HTTP interim response encoding. Try to release buffer to be
+ * able to encode newer interim or final response.
+ */
+ if (qcc_release_stream_txbuf(qcs)) {
+ TRACE_DEVEL("cannot release buf", H3_EV_TX_FRAME|H3_EV_TX_HDR, qcs->qcc->conn, qcs);
+ return 0;
+ }
+
+ TRACE_DEVEL("retry after buf release", H3_EV_TX_FRAME|H3_EV_TX_HDR, qcs->qcc->conn, qcs);
+ goto retry;
+ }
+
if (smallbuf) {
TRACE_DEVEL("retry with a full buffer", H3_EV_TX_FRAME|H3_EV_TX_HDR, qcs->qcc->conn, qcs);
smallbuf = 0;