]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: channel: compare to_forward with buf->i, not buf->size
authorWilly Tarreau <w@1wt.eu>
Tue, 13 Jan 2015 18:07:23 +0000 (19:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 14 Jan 2015 12:50:24 +0000 (13:50 +0100)
We know that all incoming data are going to be purged if to_forward
is greater than them, not only if greater than the buffer size. This
buf has no direct impact on this version, but it participates to some
bugs affecting http-send-name-header since 1.4. This fix will have to
be backported down to 1.4 albeit in a different form.

include/proto/channel.h

index 3ec92186450122be1bc89c6487d84bf1bed34a19..ca08ff1cf5c0fdc7a40f8e158fad831d8f3296cb 100644 (file)
@@ -138,10 +138,13 @@ static inline int channel_full(const struct channel *chn)
        if (!rem)
                return 1; /* buffer already full */
 
-       if (chn->to_forward >= chn->buf->size ||
-           (CHN_INFINITE_FORWARD < MAX_RANGE(typeof(chn->buf->size)) && // just there to ensure gcc
-            chn->to_forward == CHN_INFINITE_FORWARD))                  // avoids the useless second
-               return 0;                                               // test whenever possible
+       /* now we know there's some room left, verify if we're touching
+        * the reserve with some permanent input data.
+        */
+       if (chn->to_forward >= chn->buf->i ||
+           (CHN_INFINITE_FORWARD < MAX_RANGE(typeof(chn->buf->i)) && // just there to ensure gcc
+            chn->to_forward == CHN_INFINITE_FORWARD))                // avoids the useless second
+               return 0;                                             // test whenever possible
 
        rem -= global.tune.maxrewrite;
        rem += chn->buf->o;
@@ -300,8 +303,8 @@ static inline int bi_avail(const struct channel *chn)
        if (!rem)
                return rem; /* buffer already full */
 
-       if (chn->to_forward >= chn->buf->size ||
-           (CHN_INFINITE_FORWARD < MAX_RANGE(typeof(chn->buf->size)) && // just there to ensure gcc
+       if (chn->to_forward >= chn->buf->i ||
+           (CHN_INFINITE_FORWARD < MAX_RANGE(typeof(chn->buf->i)) &&   // just there to ensure gcc
             chn->to_forward == CHN_INFINITE_FORWARD))                  // avoids the useless second
                return rem;                                             // test whenever possible