mirror of https://github.com/yandex/odyssey.git
odyssey: make restart read logic explicit in router attach
This commit is contained in:
parent
a3f55f4f21
commit
d784c2ad19
|
@ -84,6 +84,12 @@ od_io_detach(od_io_t *io)
|
|||
return machine_io_detach(io->io);
|
||||
}
|
||||
|
||||
static inline int
|
||||
od_io_read_active(od_io_t *io)
|
||||
{
|
||||
return machine_read_active(io->io);
|
||||
}
|
||||
|
||||
static inline int
|
||||
od_io_read_start(od_io_t *io)
|
||||
{
|
||||
|
|
|
@ -330,6 +330,7 @@ od_router_attach(od_router_t *router, od_config_t *config, od_client_t *client)
|
|||
od_client_pool_set(&route->client_pool, client, OD_CLIENT_QUEUE);
|
||||
|
||||
/* get client server from route server pool */
|
||||
bool restart_read = false;
|
||||
od_server_t *server;
|
||||
for (;;)
|
||||
{
|
||||
|
@ -349,6 +350,7 @@ od_router_attach(od_router_t *router, od_config_t *config, od_client_t *client)
|
|||
* unsubscribe from pending client read events during the time we wait
|
||||
* for an available server
|
||||
*/
|
||||
restart_read = od_io_read_active(&client->io);
|
||||
od_io_read_stop(&client->io);
|
||||
|
||||
od_route_unlock(route);
|
||||
|
@ -401,7 +403,8 @@ attach:
|
|||
od_io_attach(&server->io);
|
||||
|
||||
/* maybe restore read events subscription */
|
||||
od_io_read_start(&client->io);
|
||||
if (restart_read)
|
||||
od_io_read_start(&client->io);
|
||||
|
||||
return OD_ROUTER_OK;
|
||||
}
|
||||
|
|
|
@ -297,6 +297,9 @@ machine_iov_pending(machine_iov_t*);
|
|||
|
||||
/* read */
|
||||
|
||||
MACHINE_API int
|
||||
machine_read_active(machine_io_t*);
|
||||
|
||||
MACHINE_API int
|
||||
machine_read_start(machine_io_t*, machine_cond_t*);
|
||||
|
||||
|
|
|
@ -182,3 +182,10 @@ machine_read(machine_io_t *obj, size_t size, uint32_t time_ms)
|
|||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
MACHINE_API int
|
||||
machine_read_active(machine_io_t *obj)
|
||||
{
|
||||
mm_io_t *io = mm_cast(mm_io_t*, obj);
|
||||
return io->on_read != NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue