From: Willy Tarreau Date: Tue, 15 Sep 2009 18:32:30 +0000 (+0200) Subject: [BUG] buffer_forward() would not correctly consider data already scheduled X-Git-Tag: v1.4-dev3~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91aa577b1f0483c50bfa72b3198cf1a1ff835163;p=thirdparty%2Fhaproxy.git [BUG] buffer_forward() would not correctly consider data already scheduled The computations in buffer_forward() were only valid if buffer_forward() was used on a buffer which had no more data scheduled for forwarding. This is always the case right now so this bug is not yet triggered but it will soon be. Now we correctly discount the bytes to be forwarded from the data already present in the buffer. --- diff --git a/include/proto/buffers.h b/include/proto/buffers.h index 724d14800a..a1834196a1 100644 --- a/include/proto/buffers.h +++ b/include/proto/buffers.h @@ -100,12 +100,13 @@ static inline void buffer_forward(struct buffer *buf, unsigned int bytes) { unsigned int data_left; - buf->to_forward += bytes; data_left = buf->l - buf->send_max; - if (data_left > buf->to_forward) - data_left = buf->to_forward; + if (data_left >= bytes) { + buf->send_max += bytes; + return; + } - buf->to_forward -= data_left; + buf->to_forward += bytes - data_left; buf->send_max += data_left; }