]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua: Add error message relative to the Channel manipulation and HTTP mode
authorThierry Fournier <thierry.fournier@ozon.io>
Sat, 15 Aug 2020 12:35:51 +0000 (14:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 17 Aug 2020 10:50:43 +0000 (12:50 +0200)
When the developper try to manipulate HAProxy channels in HTTP mode,
an error throws without explanation. This patch adds an explanation.

src/hlua.c

index 6ec69e4cf3ea1554fbd24b37926b426908e52ea3..1eac9d10678ab503993a9c9e82d183061821955a 100644 (file)
@@ -2852,8 +2852,10 @@ __LJMP static int hlua_channel_dup_yield(lua_State *L, int status, lua_KContext
 
        chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        if (_hlua_channel_dup(chn, L) == 0)
                MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_channel_dup_yield, TICK_ETERNITY, 0));
@@ -2880,8 +2882,10 @@ __LJMP static int hlua_channel_get_yield(lua_State *L, int status, lua_KContext
 
        chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        ret = _hlua_channel_dup(chn, L);
        if (unlikely(ret == 0))
@@ -2920,8 +2924,10 @@ __LJMP static int hlua_channel_getline_yield(lua_State *L, int status, lua_KCont
 
        chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        ret = ci_getline_nc(chn, &blk1, &len1, &blk2, &len2);
        if (ret == 0)
@@ -2968,8 +2974,10 @@ __LJMP static int hlua_channel_append_yield(lua_State *L, int status, lua_KConte
        int ret;
        int max;
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        /* Check if the buffer is available because HAProxy doesn't allocate
         * the request buffer if its not required.
@@ -3040,8 +3048,10 @@ __LJMP static int hlua_channel_set(lua_State *L)
        chn = MAY_LJMP(hlua_checkchannel(L, 1));
        lua_pushinteger(L, 0);
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        b_set_data(&chn->buf, co_data(chn));
 
@@ -3062,8 +3072,10 @@ __LJMP static int hlua_channel_send_yield(lua_State *L, int status, lua_KContext
        int max;
        struct hlua *hlua = hlua_gethlua(L);
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        if (unlikely(channel_output_closed(chn))) {
                lua_pushinteger(L, -1);
@@ -3166,8 +3178,10 @@ __LJMP static int hlua_channel_forward_yield(lua_State *L, int status, lua_KCont
 
        chn = MAY_LJMP(hlua_checkchannel(L, 1));
 
-       if (chn_strm(chn)->be->mode == PR_MODE_HTTP)
+       if (chn_strm(chn)->be->mode == PR_MODE_HTTP) {
+               lua_pushfstring(L, "Cannot manipulate HAProxy channels in HTTP mode.");
                WILL_LJMP(lua_error(L));
+       }
 
        len = MAY_LJMP(luaL_checkinteger(L, 2));
        l = MAY_LJMP(luaL_checkinteger(L, -1));