]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stream: Forward the right amount of data before infinite forwarding
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 18 Dec 2018 20:57:24 +0000 (21:57 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 19 Dec 2018 12:45:53 +0000 (13:45 +0100)
Before setting the infinite forward, we first forward all remaining input data
from the channel. Of course for HTX streams, this must be done using the amount
of data in the HTX message not in the channel (which appears as full because of
the HTX).

src/stream.c

index 941f4897926991c032564f236ff8931133169ff5..eec2d0a1876c97f488702b322080237f8ea5c5e1 100644 (file)
@@ -2180,19 +2180,22 @@ redo:
                channel_auto_read(req);
                channel_auto_connect(req);
                channel_auto_close(req);
-               c_adv(req, ci_data(req));
 
-               if (IS_HTX_STRM(s) && s->txn) {
+               if (IS_HTX_STRM(s)) {
+                       struct htx *htx = htxbuf(&req->buf);
+
                        /* We'll let data flow between the producer (if still connected)
-                        * to the consumer (which might possibly not be connected yet).
+                        * to the consumer.
                         */
+                       co_set_data(req, htx->data);
                        if (!(req->flags & (CF_SHUTR|CF_SHUTW_NOW)))
-                               channel_htx_forward_forever(req, htxbuf(&req->buf));
+                               channel_htx_forward_forever(req, htx);
                }
                else {
                        /* We'll let data flow between the producer (if still connected)
                         * to the consumer (which might possibly not be connected yet).
                         */
+                       c_adv(req, ci_data(req));
                        if (!(req->flags & (CF_SHUTR|CF_SHUTW_NOW)))
                                channel_forward_forever(req);
 
@@ -2350,20 +2353,22 @@ redo:
                 */
                channel_auto_read(res);
                channel_auto_close(res);
-               c_adv(res, ci_data(res));
 
+               if (IS_HTX_STRM(s)) {
+                       struct htx *htx = htxbuf(&res->buf);
 
-               if (IS_HTX_STRM(s) && s->txn) {
                        /* We'll let data flow between the producer (if still connected)
                         * to the consumer.
                         */
+                       co_set_data(res, htx->data);
                        if (!(res->flags & (CF_SHUTR|CF_SHUTW_NOW)))
-                               channel_htx_forward_forever(res, htxbuf(&res->buf));
+                               channel_htx_forward_forever(res, htx);
                }
                else {
                        /* We'll let data flow between the producer (if still connected)
                         * to the consumer.
                         */
+                       c_adv(res, ci_data(res));
                        if (!(res->flags & (CF_SHUTR|CF_SHUTW_NOW)))
                                channel_forward_forever(res);