]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: Ignore the reserve to know if a channel is full or not
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Feb 2020 10:59:19 +0000 (11:59 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Mar 2020 13:13:00 +0000 (14:13 +0100)
The Lua function Channel.is_full() should not take care of the reserve because
it is not called from a producer (an applet for instance). From an action, it is
allowed to overwrite the buffer reserve.

This patch should be backported as far as 1.7. But it must be adapted for 1.8
and lower because there is no HTX on these versions.

src/hlua.c

index e6878974d79008d6662cd23732d891c34c291375..b3eca4e228c64dc5afb03652088a0c217a517c1b 100644 (file)
@@ -3122,22 +3122,13 @@ __LJMP static int hlua_channel_get_in_len(lua_State *L)
 __LJMP static int hlua_channel_is_full(lua_State *L)
 {
        struct channel *chn;
-       int rem;
 
        MAY_LJMP(check_args(L, 1, "is_full"));
        chn = MAY_LJMP(hlua_checkchannel(L, 1));
-
-       if (IS_HTX_STRM(chn_strm(chn))) {
-               struct htx *htx = htxbuf(&chn->buf);
-
-               rem = htx_free_data_space(htx);
-       }
-       else
-               rem = b_room(&chn->buf);
-
-       rem -= global.tune.maxrewrite; /* Rewrite reserved size */
-
-       lua_pushboolean(L, rem <= 0);
+       /* ignore the reserve, we are not on a producer side (ie in an
+        * applet).
+        */
+       lua_pushboolean(L, channel_full(chn, 0));
        return 1;
 }