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"
|
2017-06-20 15:39:52 +00:00
|
|
|
#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"
|
2017-06-02 13:49:20 +00:00
|
|
|
#include "od_tls.h"
|
2017-05-29 15:33:44 +00:00
|
|
|
#include "od_cancel.h"
|
|
|
|
|
2017-06-16 12:28:37 +00:00
|
|
|
int od_cancel(od_system_t *system,
|
2017-06-21 12:18:48 +00:00
|
|
|
od_schemestorage_t *server_scheme,
|
2017-06-02 13:49:20 +00:00
|
|
|
so_key_t *key,
|
2017-06-20 15:39:52 +00:00
|
|
|
od_id_t *server_id)
|
2017-05-29 15:33:44 +00:00
|
|
|
{
|
2017-06-16 12:28:37 +00:00
|
|
|
od_instance_t *instance = system->instance;
|
2017-06-02 13:49:20 +00:00
|
|
|
od_log_server(&instance->log, 0, "cancel",
|
2017-06-28 10:58:21 +00:00
|
|
|
"cancel for s%.*s", sizeof(server_id->id),
|
2017-06-20 15:39:52 +00:00
|
|
|
server_id->id);
|
2017-06-16 12:28:37 +00:00
|
|
|
od_server_t server;
|
|
|
|
od_server_init(&server);
|
|
|
|
server.system = system;
|
|
|
|
od_backend_connect_cancel(&server, server_scheme, key);
|
2017-06-02 13:49:20 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-06-16 12:28:37 +00:00
|
|
|
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;
|
2017-06-21 12:18:48 +00:00
|
|
|
od_schemestorage_t *server_scheme = route->scheme->storage;
|
2017-05-30 11:34:08 +00:00
|
|
|
so_key_t cancel_key = server->key;
|
2017-06-20 15:39:52 +00:00
|
|
|
return od_cancel(system, server_scheme, &cancel_key, &server->id);
|
2017-05-30 11:34:08 +00:00
|
|
|
}
|