]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] buffer_forward() would not correctly consider data already scheduled
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Sep 2009 18:32:30 +0000 (20:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Sep 2009 12:53:47 +0000 (14:53 +0200)
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.

include/proto/buffers.h

index 724d14800ace232c4a402cb32c94c18cc5a99ab1..a1834196a19fc4dcb372e3d28820e4f95124393a 100644 (file)
@@ -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;
 }