2017-05-25 12:01:56 +00:00
|
|
|
|
|
|
|
/*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Odissey.
|
2017-05-25 12:01:56 +00:00
|
|
|
*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Advanced PostgreSQL connection pooler.
|
2017-05-25 12:01:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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-06-14 12:14:53 +00:00
|
|
|
#include <unistd.h>
|
2017-06-20 10:40:02 +00:00
|
|
|
#include <errno.h>
|
2017-05-25 12:01:56 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include <machinarium.h>
|
2017-06-07 11:50:58 +00:00
|
|
|
#include <shapito.h>
|
2017-05-25 12:01:56 +00:00
|
|
|
|
2017-07-05 12:15:17 +00:00
|
|
|
#include "sources/macro.h"
|
|
|
|
#include "sources/version.h"
|
2017-08-08 13:50:50 +00:00
|
|
|
#include "sources/atomic.h"
|
2017-11-27 12:54:16 +00:00
|
|
|
#include "sources/util.h"
|
|
|
|
#include "sources/error.h"
|
2017-07-05 12:15:17 +00:00
|
|
|
#include "sources/list.h"
|
|
|
|
#include "sources/pid.h"
|
|
|
|
#include "sources/id.h"
|
2017-07-26 14:05:29 +00:00
|
|
|
#include "sources/logger.h"
|
2017-07-05 12:15:17 +00:00
|
|
|
#include "sources/daemon.h"
|
|
|
|
#include "sources/scheme.h"
|
2017-07-14 13:40:31 +00:00
|
|
|
#include "sources/scheme_mgr.h"
|
2017-07-05 12:15:17 +00:00
|
|
|
#include "sources/config.h"
|
|
|
|
#include "sources/msg.h"
|
|
|
|
#include "sources/system.h"
|
|
|
|
#include "sources/server.h"
|
|
|
|
#include "sources/server_pool.h"
|
|
|
|
#include "sources/client.h"
|
|
|
|
#include "sources/client_pool.h"
|
|
|
|
#include "sources/route_id.h"
|
|
|
|
#include "sources/route.h"
|
|
|
|
#include "sources/route_pool.h"
|
|
|
|
#include "sources/io.h"
|
2017-09-15 12:58:29 +00:00
|
|
|
#include "sources/instance.h"
|
2018-02-22 13:43:52 +00:00
|
|
|
#include "sources/router_cancel.h"
|
2017-07-05 12:15:17 +00:00
|
|
|
#include "sources/router.h"
|
|
|
|
#include "sources/console.h"
|
|
|
|
#include "sources/relay.h"
|
|
|
|
#include "sources/relay_pool.h"
|
|
|
|
#include "sources/pooler.h"
|
|
|
|
#include "sources/periodic.h"
|
|
|
|
#include "sources/tls.h"
|
2017-05-25 12:01:56 +00:00
|
|
|
|
|
|
|
static inline void
|
2017-06-19 14:39:12 +00:00
|
|
|
od_pooler_server(void *arg)
|
2017-05-25 12:01:56 +00:00
|
|
|
{
|
2017-06-19 14:39:12 +00:00
|
|
|
od_poolerserver_t *server = arg;
|
|
|
|
od_instance_t *instance = server->system->instance;
|
|
|
|
od_relaypool_t *relay_pool = server->system->relay_pool;
|
2017-05-25 12:01:56 +00:00
|
|
|
|
2017-06-16 14:04:32 +00:00
|
|
|
for (;;)
|
2017-05-25 12:01:56 +00:00
|
|
|
{
|
2018-02-19 13:18:55 +00:00
|
|
|
/* accepted client io is not attached to epoll context yet */
|
2017-06-13 11:57:54 +00:00
|
|
|
machine_io_t *client_io;
|
2018-02-26 12:57:26 +00:00
|
|
|
int rc;
|
|
|
|
rc = machine_accept(server->io, &client_io, server->scheme->backlog,
|
2018-02-19 13:18:55 +00:00
|
|
|
0, UINT32_MAX);
|
2017-06-14 12:35:04 +00:00
|
|
|
if (rc == -1) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "server", NULL, NULL,
|
|
|
|
"accept failed: %s",
|
2018-02-26 12:57:26 +00:00
|
|
|
machine_error(server->io));
|
2017-06-20 10:40:02 +00:00
|
|
|
int errno_ = machine_errno();
|
|
|
|
if (errno_ == EADDRINUSE)
|
|
|
|
break;
|
2017-05-25 12:01:56 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-05-30 15:04:59 +00:00
|
|
|
/* set network options */
|
2017-05-25 12:01:56 +00:00
|
|
|
machine_set_nodelay(client_io, instance->scheme.nodelay);
|
|
|
|
if (instance->scheme.keepalive > 0)
|
|
|
|
machine_set_keepalive(client_io, 1, instance->scheme.keepalive);
|
|
|
|
rc = machine_set_readahead(client_io, instance->scheme.readahead);
|
|
|
|
if (rc == -1) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "server", NULL, NULL,
|
|
|
|
"failed to set client readahead: %s",
|
2017-06-15 10:01:21 +00:00
|
|
|
machine_error(client_io));
|
2017-05-25 12:01:56 +00:00
|
|
|
machine_close(client_io);
|
|
|
|
machine_io_free(client_io);
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-26 11:49:17 +00:00
|
|
|
|
2017-05-25 12:01:56 +00:00
|
|
|
/* allocate new client */
|
|
|
|
od_client_t *client = od_client_allocate();
|
|
|
|
if (client == NULL) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "server", NULL, NULL,
|
|
|
|
"failed to allocate client object");
|
2017-05-25 12:01:56 +00:00
|
|
|
machine_close(client_io);
|
|
|
|
machine_io_free(client_io);
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-26 14:05:29 +00:00
|
|
|
od_idmgr_generate(&instance->id_mgr, &client->id, "c");
|
2017-05-25 12:01:56 +00:00
|
|
|
client->io = client_io;
|
2017-08-29 14:43:41 +00:00
|
|
|
client->scheme_listen = server->scheme;
|
2017-06-26 13:23:50 +00:00
|
|
|
client->tls = server->tls;
|
2017-12-18 14:15:32 +00:00
|
|
|
client->time_accept = machine_time();
|
2017-05-25 12:01:56 +00:00
|
|
|
|
2017-06-19 14:39:12 +00:00
|
|
|
/* create new client event and pass it to worker pool */
|
2017-06-13 11:57:54 +00:00
|
|
|
machine_msg_t *msg;
|
2017-05-25 12:01:56 +00:00
|
|
|
msg = machine_msg_create(OD_MCLIENT_NEW, sizeof(od_client_t*));
|
|
|
|
char *msg_data = machine_msg_get_data(msg);
|
|
|
|
memcpy(msg_data, &client, sizeof(od_client_t*));
|
2017-06-19 10:30:56 +00:00
|
|
|
od_relaypool_feed(relay_pool, msg);
|
2017-05-25 12:01:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-19 14:39:12 +00:00
|
|
|
static inline int
|
2018-02-26 12:57:26 +00:00
|
|
|
od_pooler_server_start(od_pooler_t *pooler, od_schemelisten_t *scheme,
|
2017-08-29 14:43:41 +00:00
|
|
|
struct addrinfo *addr)
|
2017-06-19 14:39:12 +00:00
|
|
|
{
|
2018-02-02 12:50:23 +00:00
|
|
|
od_instance_t *instance = pooler->system.instance;
|
2017-06-19 14:39:12 +00:00
|
|
|
od_poolerserver_t *server;
|
|
|
|
server = malloc(sizeof(od_poolerserver_t));
|
|
|
|
if (server == NULL) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to allocate pooler server object");
|
2017-06-19 14:39:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-08-29 14:43:41 +00:00
|
|
|
server->scheme = scheme;
|
2017-06-19 14:39:12 +00:00
|
|
|
server->addr = addr;
|
2018-02-02 12:50:23 +00:00
|
|
|
server->system = &pooler->system;
|
2018-02-26 12:57:26 +00:00
|
|
|
|
|
|
|
/* create server tls */
|
|
|
|
if (server->scheme->tls_mode != OD_TLS_DISABLE) {
|
|
|
|
server->tls = od_tls_frontend(server->scheme);
|
|
|
|
if (server->tls == NULL) {
|
|
|
|
od_error(&instance->logger, "server", NULL, NULL,
|
|
|
|
"failed to create tls handler");
|
|
|
|
free(server);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create server io */
|
|
|
|
server->io = machine_io_create();
|
|
|
|
if (server->io == NULL) {
|
|
|
|
od_error(&instance->logger, "server", NULL, NULL,
|
|
|
|
"failed to create pooler io");
|
|
|
|
if (server->tls)
|
|
|
|
machine_tls_free(server->tls);
|
|
|
|
free(server);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char addr_name[128];
|
|
|
|
od_getaddrname(server->addr, addr_name, sizeof(addr_name), 1, 1);
|
|
|
|
|
|
|
|
/* bind to listen address and port */
|
|
|
|
int rc;
|
|
|
|
rc = machine_bind(server->io, server->addr->ai_addr);
|
|
|
|
if (rc == -1) {
|
|
|
|
od_error(&instance->logger, "server", NULL, NULL,
|
|
|
|
"bind to %s failed: %s",
|
|
|
|
addr_name,
|
|
|
|
machine_error(server->io));
|
|
|
|
if (server->tls)
|
|
|
|
machine_tls_free(server->tls);
|
|
|
|
machine_close(server->io);
|
|
|
|
machine_io_free(server->io);
|
|
|
|
free(server);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
od_log(&instance->logger, "server", NULL, NULL,
|
|
|
|
"listening on %s", addr_name);
|
|
|
|
|
2017-06-19 14:39:12 +00:00
|
|
|
int64_t coroutine_id;
|
|
|
|
coroutine_id = machine_coroutine_create(od_pooler_server, server);
|
|
|
|
if (coroutine_id == -1) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to start server coroutine");
|
2018-02-26 12:57:26 +00:00
|
|
|
if (server->tls)
|
|
|
|
machine_tls_free(server->tls);
|
|
|
|
machine_close(server->io);
|
|
|
|
machine_io_free(server->io);
|
2017-06-19 14:39:12 +00:00
|
|
|
free(server);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-26 12:57:26 +00:00
|
|
|
static inline int
|
2017-06-19 14:39:12 +00:00
|
|
|
od_pooler_main(od_pooler_t *pooler)
|
|
|
|
{
|
2018-02-02 12:50:23 +00:00
|
|
|
od_instance_t *instance = pooler->system.instance;
|
2018-02-26 12:57:26 +00:00
|
|
|
int binded = 0;
|
2017-08-29 14:43:41 +00:00
|
|
|
od_list_t *i;
|
|
|
|
od_list_foreach(&instance->scheme.listen, i)
|
|
|
|
{
|
|
|
|
od_schemelisten_t *listen;
|
|
|
|
listen = od_container_of(i, od_schemelisten_t, link);
|
|
|
|
|
|
|
|
/* listen '*' */
|
|
|
|
struct addrinfo *hints_ptr = NULL;
|
|
|
|
struct addrinfo hints;
|
|
|
|
memset(&hints, 0, sizeof(struct addrinfo));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
hints.ai_flags = AI_PASSIVE;
|
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
|
|
|
char *host = listen->host;
|
|
|
|
if (strcmp(listen->host, "*") == 0) {
|
|
|
|
hints_ptr = &hints;
|
|
|
|
host = NULL;
|
|
|
|
}
|
2017-06-19 14:39:12 +00:00
|
|
|
|
2017-08-29 14:43:41 +00:00
|
|
|
/* resolve listen address and port */
|
|
|
|
char port[16];
|
2017-11-27 12:54:16 +00:00
|
|
|
od_snprintf(port, sizeof(port), "%d", listen->port);
|
2017-08-29 14:43:41 +00:00
|
|
|
struct addrinfo *ai = NULL;
|
|
|
|
int rc;
|
|
|
|
rc = machine_getaddrinfo(host, port, hints_ptr, &ai, UINT32_MAX);
|
|
|
|
if (rc != 0) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to resolve %s:%d",
|
2017-08-29 14:43:41 +00:00
|
|
|
listen->host,
|
|
|
|
listen->port);
|
2017-08-30 13:56:13 +00:00
|
|
|
continue;
|
2017-08-29 14:43:41 +00:00
|
|
|
}
|
|
|
|
pooler->addr = ai;
|
2017-06-19 14:39:12 +00:00
|
|
|
|
2017-08-29 14:43:41 +00:00
|
|
|
/* listen resolved addresses */
|
|
|
|
if (host) {
|
2018-02-26 12:57:26 +00:00
|
|
|
rc = od_pooler_server_start(pooler, listen, ai);
|
|
|
|
if (rc == 0)
|
|
|
|
binded++;
|
2017-08-30 13:56:13 +00:00
|
|
|
continue;
|
2017-08-29 14:43:41 +00:00
|
|
|
}
|
|
|
|
while (ai) {
|
2018-02-26 12:57:26 +00:00
|
|
|
rc = od_pooler_server_start(pooler, listen, ai);
|
|
|
|
if (rc == 0)
|
|
|
|
binded++;
|
2017-08-29 14:43:41 +00:00
|
|
|
ai = ai->ai_next;
|
|
|
|
}
|
2017-06-19 14:39:12 +00:00
|
|
|
}
|
2018-02-26 12:57:26 +00:00
|
|
|
|
|
|
|
return binded;
|
2017-06-19 14:39:12 +00:00
|
|
|
}
|
|
|
|
|
2017-06-14 12:14:53 +00:00
|
|
|
static inline void
|
2017-07-19 11:29:23 +00:00
|
|
|
od_pooler_config_import(od_pooler_t *pooler)
|
|
|
|
{
|
2018-02-02 12:50:23 +00:00
|
|
|
od_instance_t *instance = pooler->system.instance;
|
2017-07-19 11:29:23 +00:00
|
|
|
|
2017-09-21 13:44:19 +00:00
|
|
|
od_log(&instance->logger, "config", NULL, NULL, "importing changes from '%s'",
|
2017-07-19 11:29:23 +00:00
|
|
|
instance->config_file);
|
|
|
|
|
|
|
|
od_scheme_t scheme;
|
|
|
|
od_scheme_init(&scheme);
|
2017-08-03 14:03:37 +00:00
|
|
|
uint64_t scheme_version;
|
2017-08-01 15:16:29 +00:00
|
|
|
scheme_version = od_schememgr_version_next(&instance->scheme_mgr);
|
2017-09-15 13:52:11 +00:00
|
|
|
|
|
|
|
od_error_t error;
|
|
|
|
od_error_init(&error);
|
2017-07-19 11:29:23 +00:00
|
|
|
int rc;
|
2017-09-15 13:52:11 +00:00
|
|
|
rc = od_config_load(&scheme, &error, instance->config_file,
|
2017-08-01 15:16:29 +00:00
|
|
|
scheme_version);
|
2017-07-19 11:29:23 +00:00
|
|
|
if (rc == -1) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "config", NULL, NULL,
|
|
|
|
"%s", error.error);
|
2017-07-19 11:29:23 +00:00
|
|
|
od_scheme_free(&scheme);
|
|
|
|
return;
|
|
|
|
}
|
2017-07-26 14:05:29 +00:00
|
|
|
rc = od_scheme_validate(&scheme, &instance->logger);
|
2017-07-19 11:29:23 +00:00
|
|
|
if (rc == -1) {
|
|
|
|
od_scheme_free(&scheme);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Merge configuration changes.
|
|
|
|
*
|
2017-07-24 12:06:18 +00:00
|
|
|
* Add new routes or obsolete previous ones which are updated or not
|
2017-07-19 11:29:23 +00:00
|
|
|
* present in new config file.
|
|
|
|
*/
|
2017-07-24 12:06:18 +00:00
|
|
|
int has_updates;
|
2017-07-26 14:05:29 +00:00
|
|
|
has_updates = od_scheme_merge(&instance->scheme, &instance->logger, &scheme);
|
2017-07-19 11:29:23 +00:00
|
|
|
|
|
|
|
/* free unused settings */
|
|
|
|
od_scheme_free(&scheme);
|
2017-07-24 12:06:18 +00:00
|
|
|
|
|
|
|
if (has_updates && instance->scheme.log_config)
|
2017-07-26 14:05:29 +00:00
|
|
|
od_scheme_print(&instance->scheme, &instance->logger, 1);
|
2017-07-19 11:29:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_pooler_signal_handler(void *arg)
|
2017-06-14 12:14:53 +00:00
|
|
|
{
|
|
|
|
od_pooler_t *pooler = arg;
|
2018-02-02 12:50:23 +00:00
|
|
|
od_instance_t *instance = pooler->system.instance;
|
2017-06-14 12:14:53 +00:00
|
|
|
|
|
|
|
sigset_t mask;
|
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, SIGINT);
|
2017-07-13 11:49:44 +00:00
|
|
|
sigaddset(&mask, SIGHUP);
|
2017-06-14 12:14:53 +00:00
|
|
|
int rc;
|
|
|
|
rc = machine_signal_init(&mask);
|
|
|
|
if (rc == -1) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to init signal handler");
|
2017-06-14 12:14:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
rc = machine_signal_wait(UINT32_MAX);
|
|
|
|
if (rc == -1)
|
|
|
|
break;
|
|
|
|
switch (rc) {
|
|
|
|
case SIGINT:
|
2017-09-21 13:44:19 +00:00
|
|
|
od_log(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"SIGINT received, shutting down");
|
2017-06-15 13:29:30 +00:00
|
|
|
|
2017-06-14 12:35:04 +00:00
|
|
|
exit(0);
|
2017-06-14 12:14:53 +00:00
|
|
|
break;
|
2017-07-13 11:49:44 +00:00
|
|
|
case SIGHUP:
|
2017-09-21 13:44:19 +00:00
|
|
|
od_log(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"SIGHUP received");
|
2017-07-19 11:29:23 +00:00
|
|
|
od_pooler_config_import(pooler);
|
2017-07-13 11:49:44 +00:00
|
|
|
break;
|
2017-06-14 12:14:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-05 14:05:39 +00:00
|
|
|
static inline void
|
|
|
|
od_pooler(void *arg)
|
|
|
|
{
|
|
|
|
od_pooler_t *pooler = arg;
|
2018-02-02 12:50:23 +00:00
|
|
|
od_instance_t *instance = pooler->instance;
|
2017-06-14 12:14:53 +00:00
|
|
|
|
2017-06-05 14:05:39 +00:00
|
|
|
/* start router coroutine */
|
|
|
|
int rc;
|
2018-02-02 12:50:23 +00:00
|
|
|
od_router_t *router = pooler->system.router;
|
2017-06-05 14:05:39 +00:00
|
|
|
rc = od_router_start(router);
|
|
|
|
if (rc == -1)
|
|
|
|
return;
|
|
|
|
|
2017-06-24 14:59:28 +00:00
|
|
|
/* start console coroutine */
|
2018-02-02 12:50:23 +00:00
|
|
|
od_console_t *console = pooler->system.console;
|
2017-06-24 14:59:28 +00:00
|
|
|
rc = od_console_start(console);
|
|
|
|
if (rc == -1)
|
|
|
|
return;
|
|
|
|
|
2017-06-05 14:05:39 +00:00
|
|
|
/* start periodic coroutine */
|
2018-02-02 12:50:23 +00:00
|
|
|
od_periodic_t *periodic = pooler->system.periodic;
|
2017-06-05 14:05:39 +00:00
|
|
|
rc = od_periodic_start(periodic);
|
|
|
|
if (rc == -1)
|
|
|
|
return;
|
|
|
|
|
2018-02-02 11:54:13 +00:00
|
|
|
/* start worker threads */
|
2018-02-02 12:50:23 +00:00
|
|
|
od_relaypool_t *relay_pool = pooler->system.relay_pool;
|
|
|
|
rc = od_relaypool_start(relay_pool, &pooler->system, instance->scheme.workers);
|
2018-02-02 11:54:13 +00:00
|
|
|
if (rc == -1)
|
|
|
|
return;
|
|
|
|
|
2018-02-02 12:50:23 +00:00
|
|
|
/* start signal handler coroutine */
|
|
|
|
int64_t coroutine_id;
|
|
|
|
coroutine_id = machine_coroutine_create(od_pooler_signal_handler, pooler);
|
|
|
|
if (coroutine_id == -1) {
|
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to start signal handler");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-24 14:59:28 +00:00
|
|
|
/* start pooler servers */
|
2018-02-26 12:57:26 +00:00
|
|
|
rc = od_pooler_main(pooler);
|
|
|
|
if (rc == 0) {
|
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to bind any listen address");
|
|
|
|
exit(1);
|
|
|
|
}
|
2017-06-05 14:05:39 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 12:50:23 +00:00
|
|
|
int od_pooler_init(od_pooler_t *pooler, od_instance_t *instance)
|
2017-05-25 12:01:56 +00:00
|
|
|
{
|
2018-02-02 12:50:23 +00:00
|
|
|
pooler->machine = -1;
|
|
|
|
pooler->instance = instance;
|
|
|
|
pooler->addr = NULL;
|
|
|
|
memset(&pooler->system, 0, sizeof(pooler->system));
|
2017-05-26 11:49:17 +00:00
|
|
|
return 0;
|
2017-05-25 12:01:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int od_pooler_start(od_pooler_t *pooler)
|
|
|
|
{
|
2018-02-02 12:50:23 +00:00
|
|
|
od_instance_t *instance = pooler->system.instance;
|
2017-05-25 12:01:56 +00:00
|
|
|
pooler->machine = machine_create("pooler", od_pooler, pooler);
|
|
|
|
if (pooler->machine == -1) {
|
2017-09-21 13:44:19 +00:00
|
|
|
od_error(&instance->logger, "pooler", NULL, NULL,
|
|
|
|
"failed to create pooler thread");
|
2017-06-19 10:30:56 +00:00
|
|
|
return -1;
|
2017-05-25 12:01:56 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|