diff --git a/src/hlua.c b/src/hlua.c index f9f7c3006..39b64dc38 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -278,6 +278,7 @@ struct hlua_csk_ctx { struct list wake_on_read; struct list wake_on_write; struct appctx *appctx; + struct server *srv; int timeout; int die; }; @@ -3183,6 +3184,10 @@ __LJMP static int hlua_socket_connect(struct lua_State *L) return 1; } + csk_ctx = container_of(peer, struct hlua_csk_ctx, xref); + if (!csk_ctx->srv) + csk_ctx->srv = socket_tcp; + /* Parse ip address. */ addr = str2sa_range(ip, NULL, &low, &high, NULL, NULL, NULL, NULL, NULL, PA_O_PORT_OK | PA_O_STREAM); if (!addr) { @@ -3263,6 +3268,7 @@ __LJMP static int hlua_socket_connect_ssl(struct lua_State *L) } s = appctx_strm(container_of(peer, struct hlua_csk_ctx, xref)->appctx); + container_of(peer, struct hlua_csk_ctx, xref)->srv = socket_ssl; s->target = &socket_ssl->obj_type; xref_unlock(&socket->xref, peer); @@ -3378,6 +3384,7 @@ __LJMP static int hlua_socket_new(lua_State *L) ctx = applet_reserve_svcctx(appctx, sizeof(*ctx)); ctx->connected = 0; ctx->die = 0; + ctx->srv = NULL; ctx->timeout = 0; ctx->appctx = appctx; LIST_INIT(&ctx->wake_on_write);