odyssey/sources/od_cancel.c

90 lines
2.0 KiB
C
Raw Normal View History

2017-05-29 15:33:44 +00:00
/*
2017-06-07 11:50:58 +00:00
* ODISSEY.
2017-05-29 15:33:44 +00:00
*
* PostgreSQL connection pooler and request router.
*/
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
2017-05-31 15:47:15 +00:00
#include <inttypes.h>
2017-05-29 15:33:44 +00:00
#include <signal.h>
#include <machinarium.h>
2017-06-07 11:50:58 +00:00
#include <shapito.h>
2017-05-29 15:33:44 +00:00
#include "od_macro.h"
#include "od_version.h"
#include "od_list.h"
#include "od_pid.h"
#include "od_id.h"
2017-05-29 15:33:44 +00:00
#include "od_syslog.h"
#include "od_log.h"
#include "od_daemon.h"
#include "od_scheme.h"
#include "od_lex.h"
#include "od_config.h"
#include "od_msg.h"
#include "od_system.h"
#include "od_instance.h"
#include "od_server.h"
#include "od_server_pool.h"
#include "od_client.h"
#include "od_client_pool.h"
#include "od_route_id.h"
#include "od_route.h"
#include "od_route_pool.h"
#include "od_io.h"
#include "od_router.h"
2017-06-05 13:45:28 +00:00
#include "od_pooler.h"
2017-05-29 15:33:44 +00:00
#include "od_relay.h"
#include "od_frontend.h"
#include "od_backend.h"
#include "od_auth.h"
#include "od_tls.h"
2017-05-29 15:33:44 +00:00
#include "od_cancel.h"
int od_cancel(od_system_t *system,
od_schemestorage_t *server_scheme,
so_key_t *key,
od_id_t *server_id)
2017-05-29 15:33:44 +00:00
{
od_instance_t *instance = system->instance;
od_log_server(&instance->log, 0, "cancel",
2017-06-28 10:58:21 +00:00
"cancel for s%.*s", sizeof(server_id->id),
server_id->id);
od_server_t server;
od_server_init(&server);
server.system = system;
od_backend_connect_cancel(&server, server_scheme, key);
od_backend_close(&server);
2017-05-29 15:33:44 +00:00
return 0;
}
2017-05-30 11:34:08 +00:00
static inline int
od_cancel_cmp(od_server_t *server, void *arg)
{
so_key_t *key = arg;
return so_keycmp(&server->key_client, key);
}
int od_cancel_match(od_system_t *system,
2017-05-30 11:34:08 +00:00
od_routepool_t *route_pool,
so_key_t *key)
{
/* match server by client key (forge) */
od_server_t *server;
server = od_routepool_foreach(route_pool, OD_SACTIVE, od_cancel_cmp, key);
if (server == NULL)
return -1;
od_route_t *route = server->route;
od_schemestorage_t *server_scheme = route->scheme->storage;
2017-05-30 11:34:08 +00:00
so_key_t cancel_key = server->key;
return od_cancel(system, server_scheme, &cancel_key, &server->id);
2017-05-30 11:34:08 +00:00
}