]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: cannot connect socket
authorThierry FOURNIER <tfournier@exceliance.fr>
Mon, 9 Mar 2015 17:12:40 +0000 (18:12 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Mar 2015 17:46:48 +0000 (18:46 +0100)
The Lua stack is not waked up when the connect() receive a positive
or negatibe response. This patch adds a signal to wake up the Lua
stack.

src/hlua.c

index 73bd94c2ac323e4d808031ce9f2115c0ed3d471b..260646bc9476f1e26918cff4fe14792b1cfa4026 100644 (file)
@@ -1658,6 +1658,8 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
        int port;
        const char *ip;
        struct connection *conn;
+       struct hlua *hlua;
+       struct appctx *appctx;
 
        MAY_LJMP(check_args(L, 3, "connect"));
 
@@ -1687,6 +1689,10 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
         */
        task_wakeup(socket->s->task, TASK_WOKEN_INIT);
 
+       hlua = hlua_gethlua(L);
+       appctx = objt_appctx(socket->s->si[0].end);
+       if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
+               WILL_LJMP(luaL_error(L, "out of memory"));
        WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_connect_yield, TICK_ETERNITY, 0));
 
        return 0;