Skip to content

Commit f41e684

Browse files
committed
BUG/MINOR: hlua: fix return with push nil on proxy check
hlua_check_proxy() may now return NULL if the target proxy instance has been flagged for deletion. Thus, proxies method have been adjusted and may push nil to report such case. This patch fixes these error paths. When nil is pushed, 1 must be returned instead of 0. This represents the count of pushed values on the stack which can be retrieved by the caller. No need to backport.
1 parent e07a75c commit f41e684

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/hlua_fcn.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ int hlua_proxy_get_name(lua_State *L)
19881988
px = hlua_check_proxy(L, 1);
19891989
if (px == NULL) {
19901990
lua_pushnil(L);
1991-
return 0;
1991+
return 1;
19921992
}
19931993

19941994
lua_pushstring(L, px->id);
@@ -2003,7 +2003,7 @@ int hlua_proxy_get_uuid(lua_State *L)
20032003
px = hlua_check_proxy(L, 1);
20042004
if (px == NULL) {
20052005
lua_pushnil(L);
2006-
return 0;
2006+
return 1;
20072007
}
20082008

20092009
snprintf(buffer, sizeof(buffer), "%d", px->uuid);
@@ -2086,7 +2086,7 @@ int hlua_proxy_get_cap(lua_State *L)
20862086
px = hlua_check_proxy(L, 1);
20872087
if (px == NULL) {
20882088
lua_pushnil(L);
2089-
return 0;
2089+
return 1;
20902090
}
20912091

20922092
str = proxy_cap_str(px->cap);
@@ -2102,7 +2102,7 @@ int hlua_proxy_get_stats(lua_State *L)
21022102
px = hlua_check_proxy(L, 1);
21032103
if (px == NULL) {
21042104
lua_pushnil(L);
2105-
return 0;
2105+
return 1;
21062106
}
21072107

21082108
if (px->cap & PR_CAP_BE)
@@ -2127,7 +2127,7 @@ int hlua_proxy_get_mode(lua_State *L)
21272127
px = hlua_check_proxy(L, 1);
21282128
if (px == NULL) {
21292129
lua_pushnil(L);
2130-
return 0;
2130+
return 1;
21312131
}
21322132

21332133
str = proxy_mode_str(px->mode);
@@ -2154,7 +2154,7 @@ int hlua_proxy_get_srv_act(lua_State *L)
21542154
px = hlua_check_proxy(L, 1);
21552155
if (px == NULL) {
21562156
lua_pushnil(L);
2157-
return 0;
2157+
return 1;
21582158
}
21592159

21602160
lua_pushinteger(L, px->srv_act);
@@ -2168,7 +2168,7 @@ int hlua_proxy_get_srv_bck(lua_State *L)
21682168
px = hlua_check_proxy(L, 1);
21692169
if (px == NULL) {
21702170
lua_pushnil(L);
2171-
return 0;
2171+
return 1;
21722172
}
21732173

21742174
lua_pushinteger(L, px->srv_bck);
@@ -2187,7 +2187,7 @@ int hlua_proxy_get_mailers(lua_State *L)
21872187
px = hlua_check_proxy(L, 1);
21882188
if (px == NULL) {
21892189
lua_pushnil(L);
2190-
return 0;
2190+
return 1;
21912191
}
21922192

21932193
if (!px->email_alert.mailers.m)

0 commit comments

Comments
 (0)