From 99c9e3684fbf3c2a7375f0aeb9e991117525b35c Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Thu, 28 Mar 2024 20:57:52 +0500 Subject: [PATCH] Revert "Revert "Do not use machinarium API while holding lock (#599)" (#601)" This reverts commit 5fcfff08210d191a4bc028fe36dcaedfd1aca71f. --- sources/router.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sources/router.c b/sources/router.c index cb0b7c6fd..905ae4ed0 100644 --- a/sources/router.c +++ b/sources/router.c @@ -344,6 +344,17 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) kiwi_be_startup_t *startup = &client->startup; od_instance_t *instance = router->global->instance; + struct sockaddr_storage sa; + int salen; + struct sockaddr *saddr; + int rc; + salen = sizeof(sa); + saddr = (struct sockaddr *)&sa; + rc = machine_getpeername(client->io.io, saddr, &salen); + if (rc == -1) { + return OD_ROUTER_ERROR; + } + /* match route */ assert(startup->database.value_len); assert(startup->user.value_len); @@ -354,23 +365,12 @@ od_router_status_t od_router_route(od_router_t *router, od_client_t *client) od_rule_t *rule = NULL; // initialize rule for (line 365) and flag '-Wmaybe-uninitialized' - struct sockaddr_storage sa; - int salen; - struct sockaddr *saddr; - int rc; switch (client->type) { case OD_POOL_CLIENT_INTERNAL: rule = od_rules_forward(&router->rules, startup->database.value, startup->user.value, NULL, 1); break; case OD_POOL_CLIENT_EXTERNAL: - salen = sizeof(sa); - saddr = (struct sockaddr *)&sa; - rc = machine_getpeername(client->io.io, saddr, &salen); - if (rc == -1) { - od_router_unlock(router); - return OD_ROUTER_ERROR; - } rule = od_rules_forward(&router->rules, startup->database.value, startup->user.value, &sa, 0); break;