2017-05-25 12:00:58 +00:00
|
|
|
#ifndef OD_CLIENT_H
|
|
|
|
#define OD_CLIENT_H
|
|
|
|
|
|
|
|
/*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Odissey.
|
2017-05-25 12:00:58 +00:00
|
|
|
*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Advanced PostgreSQL connection pooler.
|
2017-05-25 12:00:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct od_client od_client_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
OD_CUNDEF,
|
2017-05-31 10:49:12 +00:00
|
|
|
OD_CPENDING,
|
2017-05-25 12:00:58 +00:00
|
|
|
OD_CACTIVE,
|
2017-05-31 10:49:12 +00:00
|
|
|
OD_CQUEUE
|
2017-05-25 12:00:58 +00:00
|
|
|
} od_clientstate_t;
|
|
|
|
|
|
|
|
struct od_client
|
|
|
|
{
|
|
|
|
od_clientstate_t state;
|
2017-06-20 15:39:52 +00:00
|
|
|
od_id_t id;
|
2017-05-26 11:49:17 +00:00
|
|
|
uint64_t coroutine_id;
|
2017-06-07 14:59:13 +00:00
|
|
|
uint64_t coroutine_attacher_id;
|
2017-06-13 11:57:54 +00:00
|
|
|
machine_io_t *io;
|
2017-06-26 13:23:50 +00:00
|
|
|
machine_tls_t *tls;
|
2017-05-25 12:00:58 +00:00
|
|
|
od_schemeuser_t *scheme;
|
|
|
|
so_bestartup_t startup;
|
|
|
|
so_key_t key;
|
|
|
|
so_stream_t stream;
|
|
|
|
od_server_t *server;
|
|
|
|
void *route;
|
2017-05-27 14:21:39 +00:00
|
|
|
od_system_t *system;
|
2017-05-25 12:00:58 +00:00
|
|
|
od_list_t link_pool;
|
|
|
|
od_list_t link;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_client_init(od_client_t *client)
|
|
|
|
{
|
|
|
|
client->state = OD_CUNDEF;
|
2017-05-26 11:49:17 +00:00
|
|
|
client->coroutine_id = 0;
|
2017-06-07 14:59:13 +00:00
|
|
|
client->coroutine_attacher_id = 0;
|
2017-05-25 12:00:58 +00:00
|
|
|
client->io = NULL;
|
2017-06-26 13:23:50 +00:00
|
|
|
client->tls = NULL;
|
2017-05-25 12:00:58 +00:00
|
|
|
client->scheme = NULL;
|
|
|
|
client->server = NULL;
|
|
|
|
client->route = NULL;
|
2017-05-27 14:21:39 +00:00
|
|
|
client->system = NULL;
|
2017-05-25 12:00:58 +00:00
|
|
|
so_bestartup_init(&client->startup);
|
|
|
|
so_keyinit(&client->key);
|
|
|
|
so_stream_init(&client->stream);
|
|
|
|
od_list_init(&client->link_pool);
|
|
|
|
od_list_init(&client->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline od_client_t*
|
|
|
|
od_client_allocate(void)
|
|
|
|
{
|
|
|
|
od_client_t *client = malloc(sizeof(*client));
|
|
|
|
if (client == NULL)
|
|
|
|
return NULL;
|
|
|
|
od_client_init(client);
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_client_free(od_client_t *client)
|
|
|
|
{
|
|
|
|
so_bestartup_free(&client->startup);
|
|
|
|
so_stream_free(&client->stream);
|
|
|
|
free(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* OD_CLIENT_H */
|