]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hq-interop: fix tx buffering
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 7 Dec 2021 15:19:03 +0000 (16:19 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 7 Dec 2021 16:08:52 +0000 (17:08 +0100)
On h09 app layer, if there is not enought size in the tx buffer, the
transfer is interrupted and the flag QC_SF_BLK_MROOM is positionned.
The transfer is woken up by the mux when new buffer size becomes
available.

This ensure that no data is silently discarded during transfer. Without
this, once the buffer is full the data were removed and thus not send to
the client resulting in a truncating payload.

src/hq_interop.c

index 075e785b04514adc201894ea30d095f1c16beeb9..dc1e1154e636a6598f1bcf64929e4273b650154e 100644 (file)
@@ -94,6 +94,15 @@ static size_t hq_interop_snd_buf(struct conn_stream *cs, struct buffer *buf,
                case HTX_BLK_DATA:
                        if (fsize > count)
                                fsize = count;
+
+                       if (b_size(&outbuf) < fsize)
+                               fsize = b_size(&outbuf);
+
+                       if (!fsize) {
+                               qcs->flags |= QC_SF_BLK_MROOM;
+                               goto end;
+                       }
+
                        b_putblk(&outbuf, htx_get_blk_ptr(htx, blk), fsize);
                        total += fsize;
                        count -= fsize;
@@ -116,6 +125,7 @@ static size_t hq_interop_snd_buf(struct conn_stream *cs, struct buffer *buf,
                }
        }
 
+ end:
        if ((htx->flags & HTX_FL_EOM) && htx_is_empty(htx))
                qcs->flags |= QC_SF_FIN_STREAM;