odyssey/core/od_server.h

69 lines
1.2 KiB
C
Raw Normal View History

2016-11-09 11:01:08 +00:00
#ifndef OD_SERVER_H_
#define OD_SERVER_H_
/*
* odissey.
*
* PostgreSQL connection pooler and request router.
*/
typedef struct odserver_t odserver_t;
typedef enum {
OD_SUNDEF,
OD_SIDLE,
OD_SEXPIRE,
2016-11-09 11:01:08 +00:00
OD_SCONNECT,
2016-11-14 13:53:26 +00:00
OD_SRESET,
2016-11-09 11:01:08 +00:00
OD_SACTIVE
} odserver_state_t;
struct odserver_t {
2016-11-10 13:04:23 +00:00
odserver_state_t state;
sostream_t stream;
2016-11-10 13:04:23 +00:00
ftio_t io;
int is_ready;
int is_transaction;
int idle_time;
sokey_t key;
sokey_t key_client;
void *route;
2016-11-11 09:17:53 +00:00
void *pooler;
2016-11-10 13:04:23 +00:00
odlist_t link;
2016-11-09 11:01:08 +00:00
};
static inline void
od_serverinit(odserver_t *s)
{
s->state = OD_SUNDEF;
s->route = NULL;
s->io = NULL;
s->pooler = NULL;
s->idle_time = 0;
s->is_ready = 0;
s->is_transaction = 0;
2016-11-16 12:24:55 +00:00
so_keyinit(&s->key);
so_keyinit(&s->key_client);
so_stream_init(&s->stream);
2016-11-09 11:01:08 +00:00
od_listinit(&s->link);
}
static inline odserver_t*
od_serveralloc(void)
{
odserver_t *s = malloc(sizeof(*s));
if (s == NULL)
return NULL;
od_serverinit(s);
return s;
}
static inline void
od_serverfree(odserver_t *s)
{
so_stream_free(&s->stream);
2016-11-09 11:01:08 +00:00
free(s);
}
#endif