mirror of https://github.com/yandex/odyssey.git
odissey: push server back to route server pool
This commit is contained in:
parent
f5657689e5
commit
d542d4c15a
|
@ -245,7 +245,7 @@ od_frontend_session(od_client_t *client)
|
|||
|
||||
/* get server connection for the route */
|
||||
od_routerstatus_t status;
|
||||
status = od_router_attach(client->system->router, client);
|
||||
status = od_router_attach(client);
|
||||
if (status != OD_ROK)
|
||||
return OD_RS_EPOOL;
|
||||
|
||||
|
@ -350,7 +350,6 @@ od_frontend_session(od_client_t *client)
|
|||
void od_frontend(void *arg)
|
||||
{
|
||||
od_client_t *client = arg;
|
||||
od_relay_t *relay = client->system->relay;
|
||||
od_instance_t *instance = client->system->instance;
|
||||
|
||||
od_log(&instance->log, client->io, "C: new connection");
|
||||
|
@ -418,7 +417,7 @@ void od_frontend(void *arg)
|
|||
|
||||
/* route client */
|
||||
od_routerstatus_t status;
|
||||
status = od_route(relay->system->router, client);
|
||||
status = od_route(client);
|
||||
switch (status) {
|
||||
case OD_RERROR:
|
||||
od_error(&instance->log, client->io,
|
||||
|
@ -449,12 +448,13 @@ void od_frontend(void *arg)
|
|||
|
||||
od_server_t *server;
|
||||
server = client->server;
|
||||
client->server = NULL;
|
||||
|
||||
switch (rc) {
|
||||
case OD_RS_EROUTE:
|
||||
case OD_RS_EPOOL:
|
||||
case OD_RS_ELIMIT:
|
||||
assert(server == NULL);
|
||||
|
||||
break;
|
||||
case OD_RS_OK:
|
||||
case OD_RS_ECLIENT_READ:
|
||||
|
@ -476,7 +476,8 @@ void od_frontend(void *arg)
|
|||
break;
|
||||
}
|
||||
|
||||
/* TODO: DETACH server */
|
||||
/* push server to router server pool */
|
||||
od_router_detach(server);
|
||||
break;
|
||||
case OD_RS_ESERVER_CONFIGURE:
|
||||
od_log(&instance->log, server->io,
|
||||
|
|
|
@ -53,7 +53,6 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
od_route_t *route;
|
||||
od_server_t *server;
|
||||
} od_msgrouter_detach_t;
|
||||
|
||||
|
@ -220,7 +219,8 @@ od_router(void *arg)
|
|||
od_msgrouter_detach_t *msg_detach;
|
||||
msg_detach = machine_msg_get_data(msg);
|
||||
|
||||
od_serverpool_set(&msg_detach->route->server_pool,
|
||||
od_route_t *route = msg_detach->server->route;
|
||||
od_serverpool_set(&route->server_pool,
|
||||
msg_detach->server,
|
||||
OD_SIDLE);
|
||||
|
||||
|
@ -263,8 +263,10 @@ int od_router_start(od_router_t *router)
|
|||
}
|
||||
|
||||
od_routerstatus_t
|
||||
od_route(od_router_t *router, od_client_t *client)
|
||||
od_route(od_client_t *client)
|
||||
{
|
||||
od_router_t *router = client->system->router;
|
||||
|
||||
/* create response queue */
|
||||
machine_queue_t response;
|
||||
response = machine_queue_create();
|
||||
|
@ -301,8 +303,10 @@ od_route(od_router_t *router, od_client_t *client)
|
|||
}
|
||||
|
||||
od_routerstatus_t
|
||||
od_router_attach(od_router_t *router, od_client_t *client)
|
||||
od_router_attach(od_client_t *client)
|
||||
{
|
||||
od_router_t *router = client->system->router;
|
||||
|
||||
/* create response queue */
|
||||
machine_queue_t response;
|
||||
response = machine_queue_create();
|
||||
|
@ -344,12 +348,12 @@ od_router_attach(od_router_t *router, od_client_t *client)
|
|||
}
|
||||
|
||||
void
|
||||
od_router_detach(od_router_t *router, od_client_t *client)
|
||||
od_router_detach(od_server_t *server)
|
||||
{
|
||||
assert(client->server != NULL);
|
||||
od_router_t *router = server->system->router;
|
||||
|
||||
/* detach server io from clients machine context */
|
||||
machine_io_detach(client->server->io);
|
||||
machine_io_detach(server->io);
|
||||
|
||||
/* send server detach request to router */
|
||||
machine_msg_t msg;
|
||||
|
@ -358,8 +362,6 @@ od_router_detach(od_router_t *router, od_client_t *client)
|
|||
return;
|
||||
od_msgrouter_detach_t *msg_detach;
|
||||
msg_detach = machine_msg_get_data(msg);
|
||||
msg_detach->route = client->route;
|
||||
msg_detach->server = client->server;
|
||||
msg_detach->server = server;
|
||||
machine_queue_put(router->queue, msg);
|
||||
client->server = NULL;
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ int od_router_init(od_router_t*, od_system_t*);
|
|||
int od_router_start(od_router_t*);
|
||||
|
||||
od_routerstatus_t
|
||||
od_route(od_router_t*, od_client_t*);
|
||||
od_route(od_client_t*);
|
||||
|
||||
od_routerstatus_t
|
||||
od_router_attach(od_router_t*, od_client_t*);
|
||||
od_router_attach(od_client_t*);
|
||||
|
||||
void
|
||||
od_router_push(od_router_t*, od_client_t*);
|
||||
od_router_detach(od_server_t*);
|
||||
|
||||
#endif /* OD_ROUTER_H */
|
||||
|
|
Loading…
Reference in New Issue