]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua: Save the lua socket's server in its context
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 Sep 2023 15:39:44 +0000 (17:39 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Oct 2023 13:34:06 +0000 (15:34 +0200)
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

index f9f7c300685fb87dbd1994f28250aefa597e5ea3..39b64dc38c625e2891e1e15a0029bee844a30c85 100644 (file)
@@ -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);