From 6f4041c75d52ddf02a57ad643ae25bc3d835cd0f Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 27 Sep 2023 17:39:44 +0200 Subject: [PATCH] MINOR: hlua: Save the lua socket's server in its context For the same reason than the timeout, the server used by a lua socket is now saved in its context. This will be mandatory to fix issues with the lua sockets. --- src/hlua.c | 7 +++++++ 1 file changed, 7 insertions(+) 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);