odyssey/sources/client.h

77 lines
1.5 KiB
C
Raw Normal View History

#ifndef OD_CLIENT_H
#define OD_CLIENT_H
/*
2017-07-05 12:42:49 +00:00
* Odissey.
*
2017-07-05 12:42:49 +00:00
* Advanced PostgreSQL connection pooler.
*/
typedef struct od_client od_client_t;
typedef enum
{
OD_CUNDEF,
OD_CPENDING,
OD_CACTIVE,
OD_CQUEUE
} od_clientstate_t;
struct od_client
{
2017-07-06 13:36:14 +00:00
od_clientstate_t state;
od_id_t id;
uint64_t coroutine_id;
uint64_t coroutine_attacher_id;
machine_io_t *io;
machine_tls_t *tls;
od_schemeroute_t *scheme;
2017-07-06 13:36:14 +00:00
shapito_be_startup_t startup;
shapito_key_t key;
shapito_stream_t stream;
od_server_t *server;
void *route;
od_system_t *system;
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;
client->coroutine_attacher_id = 0;
client->io = NULL;
2017-06-26 13:23:50 +00:00
client->tls = NULL;
client->scheme = NULL;
client->server = NULL;
client->route = NULL;
2017-05-27 14:21:39 +00:00
client->system = NULL;
2017-07-06 13:36:14 +00:00
shapito_be_startup_init(&client->startup);
shapito_key_init(&client->key);
shapito_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)
{
2017-07-06 13:36:14 +00:00
shapito_be_startup_free(&client->startup);
shapito_stream_free(&client->stream);
free(client);
}
#endif /* OD_CLIENT_H */