MINOR: hlua: Add error message relative to the Channel manipulation and HTTP mode
When the developper try to manipulate HAProxy channels in HTTP mode,
an error throws without explanation. This patch adds an explanation.
(cherry picked from commit 77016daabed85789f858606495c3d79000f7fa6e)
[Cf: This one must be backported as far as 2.0]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 9aba445391aebdb1fc2d07d24d7fdf858dbe4aa6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/hlua.c b/src/hlua.c
index de7a9ff..8f88f6f 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -2860,8 +2860,10 @@
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));
@@ -2888,8 +2890,10 @@
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))
@@ -2928,8 +2932,10 @@
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)
@@ -2976,8 +2982,10 @@
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.
@@ -3048,8 +3056,10 @@
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));
@@ -3070,8 +3080,10 @@
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);
@@ -3174,8 +3186,10 @@
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));