mirror of https://github.com/yandex/odyssey.git
odissey: avoid io attach/detach for non shared instance
This commit is contained in:
parent
b0635265a1
commit
26efd303d1
|
@ -910,13 +910,15 @@ void od_frontend(void *arg)
|
|||
|
||||
/* attach client io to relay machine event loop */
|
||||
int rc;
|
||||
rc = machine_io_attach(client->io);
|
||||
if (rc == -1) {
|
||||
od_error(&instance->logger, "startup", client, NULL,
|
||||
"failed to transfer client io");
|
||||
machine_close(client->io);
|
||||
od_client_free(client);
|
||||
return;
|
||||
if (instance->is_shared) {
|
||||
rc = machine_io_attach(client->io);
|
||||
if (rc == -1) {
|
||||
od_error(&instance->logger, "startup", client, NULL,
|
||||
"failed to transfer client io");
|
||||
machine_close(client->io);
|
||||
od_client_free(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* handle startup */
|
||||
|
|
|
@ -265,7 +265,8 @@ od_periodic_expire(od_periodic_t *periodic)
|
|||
server->route = NULL;
|
||||
od_serverpool_set(&route->server_pool, server, OD_SUNDEF);
|
||||
|
||||
machine_io_attach(server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_attach(server->io);
|
||||
|
||||
od_backend_terminate(server);
|
||||
od_backend_close(server);
|
||||
|
|
|
@ -126,14 +126,16 @@ od_pooler_server(void *arg)
|
|||
}
|
||||
|
||||
/* detach io from pooler event loop */
|
||||
rc = machine_io_detach(client_io);
|
||||
if (rc == -1) {
|
||||
od_error(&instance->logger, "server", NULL, NULL,
|
||||
"failed to transfer client io: %s",
|
||||
machine_error(client_io));
|
||||
machine_close(client_io);
|
||||
machine_io_free(client_io);
|
||||
continue;
|
||||
if (instance->is_shared) {
|
||||
rc = machine_io_detach(client_io);
|
||||
if (rc == -1) {
|
||||
od_error(&instance->logger, "server", NULL, NULL,
|
||||
"failed to transfer client io: %s",
|
||||
machine_error(client_io));
|
||||
machine_close(client_io);
|
||||
machine_io_free(client_io);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* allocate new client */
|
||||
|
|
|
@ -405,7 +405,8 @@ od_router(void *arg)
|
|||
server->client = NULL;
|
||||
server->route = NULL;
|
||||
|
||||
machine_io_attach(server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_attach(server->io);
|
||||
od_backend_close(server);
|
||||
|
||||
msg_detach->status = OD_ROK;
|
||||
|
@ -434,7 +435,8 @@ od_router(void *arg)
|
|||
assert(router->clients > 0);
|
||||
router->clients--;
|
||||
|
||||
machine_io_attach(server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_attach(server->io);
|
||||
od_backend_terminate(server);
|
||||
od_backend_close(server);
|
||||
|
||||
|
@ -558,12 +560,13 @@ od_unroute(od_client_t *client)
|
|||
od_routerstatus_t
|
||||
od_router_attach(od_client_t *client)
|
||||
{
|
||||
od_instance_t *instance = client->system->instance;
|
||||
od_routerstatus_t status;
|
||||
status = od_router_do(client, OD_MROUTER_ATTACH, 1);
|
||||
od_server_t *server = client->server;
|
||||
if (server && server->io) {
|
||||
/* attach server io to clients machine context */
|
||||
if (server->io)
|
||||
/* attach server io to clients machine context */
|
||||
if (instance->is_shared) {
|
||||
if (server && server->io)
|
||||
machine_io_attach(server->io);
|
||||
}
|
||||
return status;
|
||||
|
@ -572,32 +575,40 @@ od_router_attach(od_client_t *client)
|
|||
od_routerstatus_t
|
||||
od_router_detach(od_client_t *client)
|
||||
{
|
||||
od_instance_t *instance = client->system->instance;
|
||||
/* detach server io from clients machine context */
|
||||
machine_io_detach(client->server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_detach(client->server->io);
|
||||
return od_router_do(client, OD_MROUTER_DETACH, 1);
|
||||
}
|
||||
|
||||
od_routerstatus_t
|
||||
od_router_detach_and_unroute(od_client_t *client)
|
||||
{
|
||||
od_instance_t *instance = client->system->instance;
|
||||
/* detach server io from clients machine context */
|
||||
machine_io_detach(client->server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_detach(client->server->io);
|
||||
return od_router_do(client, OD_MROUTER_DETACH_AND_UNROUTE, 1);
|
||||
}
|
||||
|
||||
od_routerstatus_t
|
||||
od_router_close(od_client_t *client)
|
||||
{
|
||||
od_instance_t *instance = client->system->instance;
|
||||
/* detach server io from clients machine context */
|
||||
machine_io_detach(client->server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_detach(client->server->io);
|
||||
return od_router_do(client, OD_MROUTER_CLOSE, 1);
|
||||
}
|
||||
|
||||
od_routerstatus_t
|
||||
od_router_close_and_unroute(od_client_t *client)
|
||||
{
|
||||
od_instance_t *instance = client->system->instance;
|
||||
/* detach server io from clients machine context */
|
||||
machine_io_detach(client->server->io);
|
||||
if (instance->is_shared)
|
||||
machine_io_detach(client->server->io);
|
||||
return od_router_do(client, OD_MROUTER_CLOSE_AND_UNROUTE, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue