mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MINOR: lua: Socket.send threw runtime error: 'close' needs 1 arguments.
Function `hlua_socket_close` expected exactly one argument on the Lua stack. But when `hlua_socket_close` was called from `hlua_socket_write_yield`, Lua stack had 3 arguments. So `hlua_socket_close` threw the exception with message "'close' needs 1 arguments". Introduced new helper function `hlua_socket_close_helper`, which removed the Lua stack argument count check and only checked if the first argument was a socket. This fix should be backported to 1.8, 1.7 and 1.6.
This commit is contained in:
parent
03f4ec47d9
commit
05ed330d72
14
src/hlua.c
14
src/hlua.c
@ -1629,14 +1629,12 @@ __LJMP static int hlua_socket_gc(lua_State *L)
|
|||||||
/* The close function send shutdown signal and break the
|
/* The close function send shutdown signal and break the
|
||||||
* links between the stream and the object.
|
* links between the stream and the object.
|
||||||
*/
|
*/
|
||||||
__LJMP static int hlua_socket_close(lua_State *L)
|
__LJMP static int hlua_socket_close_helper(lua_State *L)
|
||||||
{
|
{
|
||||||
struct hlua_socket *socket;
|
struct hlua_socket *socket;
|
||||||
struct appctx *appctx;
|
struct appctx *appctx;
|
||||||
struct xref *peer;
|
struct xref *peer;
|
||||||
|
|
||||||
MAY_LJMP(check_args(L, 1, "close"));
|
|
||||||
|
|
||||||
socket = MAY_LJMP(hlua_checksocket(L, 1));
|
socket = MAY_LJMP(hlua_checksocket(L, 1));
|
||||||
|
|
||||||
/* Check if we run on the same thread than the xreator thread.
|
/* Check if we run on the same thread than the xreator thread.
|
||||||
@ -1659,6 +1657,14 @@ __LJMP static int hlua_socket_close(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The close function calls close_helper.
|
||||||
|
*/
|
||||||
|
__LJMP static int hlua_socket_close(lua_State *L)
|
||||||
|
{
|
||||||
|
MAY_LJMP(check_args(L, 1, "close"));
|
||||||
|
return hlua_socket_close_helper(L);
|
||||||
|
}
|
||||||
|
|
||||||
/* This Lua function assumes that the stack contain three parameters.
|
/* This Lua function assumes that the stack contain three parameters.
|
||||||
* 1 - USERDATA containing a struct socket
|
* 1 - USERDATA containing a struct socket
|
||||||
* 2 - INTEGER with values of the macro defined below
|
* 2 - INTEGER with values of the macro defined below
|
||||||
@ -1990,7 +1996,7 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
|
|||||||
if (len == -1)
|
if (len == -1)
|
||||||
s->req.flags |= CF_WAKE_WRITE;
|
s->req.flags |= CF_WAKE_WRITE;
|
||||||
|
|
||||||
MAY_LJMP(hlua_socket_close(L));
|
MAY_LJMP(hlua_socket_close_helper(L));
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
lua_pushinteger(L, -1);
|
lua_pushinteger(L, -1);
|
||||||
xref_unlock(&socket->xref, peer);
|
xref_unlock(&socket->xref, peer);
|
||||||
|
Loading…
Reference in New Issue
Block a user