From 2dba1a50c366e3820b38a50b4a54c3845dc9530d Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 18 Dec 2018 21:57:24 +0100 Subject: [PATCH] BUG/MEDIUM: stream: Forward the right amount of data before infinite forwarding 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 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/stream.c b/src/stream.c index 941f48979..eec2d0a18 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2180,19 +2180,22 @@ struct task *process_stream(struct task *t, void *context, unsigned short state) 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 @@ struct task *process_stream(struct task *t, void *context, unsigned short state) */ 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);