Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Do not use machinarium API while holding lock"" #602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions sources/router.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Loading