mirror of https://github.com/yandex/odyssey.git
odissey: new naming scheme: od_list_t
This commit is contained in:
parent
ab9245c2db
commit
93740c91fb
|
@ -17,7 +17,7 @@ struct odclient_t {
|
|||
odserver_t *server;
|
||||
void *pooler;
|
||||
uint64_t id;
|
||||
odlist_t link;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
static inline void
|
||||
|
|
|
@ -36,7 +36,7 @@ void od_clientpool_init(odclient_pool_t *p)
|
|||
void od_clientpool_free(odclient_pool_t *p)
|
||||
{
|
||||
odclient_t *client;
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&p->list, i, n) {
|
||||
client = od_container_of(i, odclient_t, link);
|
||||
/* ... */
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
typedef struct odclient_pool_t odclient_pool_t;
|
||||
|
||||
struct odclient_pool_t {
|
||||
odlist_t list;
|
||||
int count;
|
||||
od_list_t list;
|
||||
int count;
|
||||
};
|
||||
|
||||
void od_clientpool_init(odclient_pool_t*);
|
||||
|
|
|
@ -32,7 +32,7 @@ void od_lexopen(od_lex_t *l, od_keyword_t *list, char *buf, int size)
|
|||
|
||||
void od_lexfree(od_lex_t *l)
|
||||
{
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&l->list, i, n) {
|
||||
od_token_t *tk = od_container_of(i, od_token_t, link_alloc);
|
||||
if (tk->id == OD_LSTRING ||
|
||||
|
|
|
@ -34,8 +34,8 @@ struct od_token_t {
|
|||
char *string;
|
||||
} v;
|
||||
int line;
|
||||
odlist_t link_alloc;
|
||||
odlist_t link;
|
||||
od_list_t link_alloc;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
struct od_lex_t {
|
||||
|
@ -45,8 +45,8 @@ struct od_lex_t {
|
|||
int line;
|
||||
od_keyword_t *keywords;
|
||||
int count;
|
||||
odlist_t stack;
|
||||
odlist_t list;
|
||||
od_list_t stack;
|
||||
od_list_t list;
|
||||
char *error;
|
||||
};
|
||||
|
||||
|
|
|
@ -7,20 +7,20 @@
|
|||
* PostgreSQL connection pooler and request router.
|
||||
*/
|
||||
|
||||
typedef struct odlist_t odlist_t;
|
||||
typedef struct od_list_t od_list_t;
|
||||
|
||||
struct odlist_t {
|
||||
odlist_t *next, *prev;
|
||||
struct od_list_t {
|
||||
od_list_t *next, *prev;
|
||||
};
|
||||
|
||||
static inline void
|
||||
od_listinit(odlist_t *list)
|
||||
od_listinit(od_list_t *list)
|
||||
{
|
||||
list->next = list->prev = list;
|
||||
}
|
||||
|
||||
static inline void
|
||||
od_listappend(odlist_t *list, odlist_t *node)
|
||||
od_listappend(od_list_t *list, od_list_t *node)
|
||||
{
|
||||
node->next = list;
|
||||
node->prev = list->prev;
|
||||
|
@ -29,14 +29,14 @@ od_listappend(odlist_t *list, odlist_t *node)
|
|||
}
|
||||
|
||||
static inline void
|
||||
od_listunlink(odlist_t *node)
|
||||
od_listunlink(od_list_t *node)
|
||||
{
|
||||
node->prev->next = node->next;
|
||||
node->next->prev = node->prev;
|
||||
}
|
||||
|
||||
static inline void
|
||||
od_listpush(odlist_t *list, odlist_t *node)
|
||||
od_listpush(od_list_t *list, od_list_t *node)
|
||||
{
|
||||
node->next = list->next;
|
||||
node->prev = list;
|
||||
|
@ -44,16 +44,16 @@ od_listpush(odlist_t *list, odlist_t *node)
|
|||
node->next->prev = node;
|
||||
}
|
||||
|
||||
static inline odlist_t*
|
||||
od_listpop(odlist_t *list)
|
||||
static inline od_list_t*
|
||||
od_listpop(od_list_t *list)
|
||||
{
|
||||
register odlist_t *pop = list->next;
|
||||
register od_list_t *pop = list->next;
|
||||
od_listunlink(pop);
|
||||
return pop;
|
||||
}
|
||||
|
||||
static inline int
|
||||
od_listempty(odlist_t *list)
|
||||
od_listempty(od_list_t *list)
|
||||
{
|
||||
return list->next == list && list->prev == list;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ struct odroute_t {
|
|||
odscheme_route_t *scheme;
|
||||
odroute_id_t id;
|
||||
odserver_pool_t server_pool;
|
||||
odlist_t link;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
static inline void
|
||||
|
|
|
@ -38,7 +38,7 @@ void od_routepool_init(odroute_pool_t *pool)
|
|||
void od_routepool_free(odroute_pool_t *pool)
|
||||
{
|
||||
odroute_t *route;
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&pool->list, i, n) {
|
||||
route = od_container_of(i, odroute_t, link);
|
||||
od_routefree(route);
|
||||
|
@ -76,7 +76,7 @@ odroute_t*
|
|||
od_routepool_match(odroute_pool_t *pool, odroute_id_t *key)
|
||||
{
|
||||
odroute_t *route;
|
||||
odlist_t *i;
|
||||
od_list_t *i;
|
||||
od_listforeach(&pool->list, i) {
|
||||
route = od_container_of(i, odroute_t, link);
|
||||
if (od_routeid_compare(&route->id, key))
|
||||
|
@ -89,7 +89,7 @@ odserver_t*
|
|||
od_routepool_pop(odroute_pool_t *pool, odserver_state_t state)
|
||||
{
|
||||
odroute_t *route;
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&pool->list, i, n) {
|
||||
route = od_container_of(i, odroute_t, link);
|
||||
odserver_t *server =
|
||||
|
@ -106,7 +106,7 @@ od_routepool_foreach(odroute_pool_t *pool, odserver_state_t state,
|
|||
void *arg)
|
||||
{
|
||||
odroute_t *route;
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&pool->list, i, n) {
|
||||
route = od_container_of(i, odroute_t, link);
|
||||
odserver_t *server =
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
typedef struct odroute_pool_t odroute_pool_t;
|
||||
|
||||
struct odroute_pool_t {
|
||||
odlist_t list;
|
||||
int count;
|
||||
od_list_t list;
|
||||
int count;
|
||||
};
|
||||
|
||||
void od_routepool_init(odroute_pool_t*);
|
||||
|
|
|
@ -45,7 +45,7 @@ void od_schemeinit(odscheme_t *scheme)
|
|||
|
||||
void od_schemefree(odscheme_t *scheme)
|
||||
{
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&scheme->servers, i, n) {
|
||||
odscheme_server_t *server;
|
||||
server = od_container_of(i, odscheme_server_t, link);
|
||||
|
@ -75,7 +75,7 @@ od_schemeserver_add(odscheme_t *scheme)
|
|||
odscheme_server_t*
|
||||
od_schemeserver_match(odscheme_t *scheme, char *name)
|
||||
{
|
||||
odlist_t *i;
|
||||
od_list_t *i;
|
||||
od_listforeach(&scheme->servers, i) {
|
||||
odscheme_server_t *server;
|
||||
server = od_container_of(i, odscheme_server_t, link);
|
||||
|
@ -88,7 +88,7 @@ od_schemeserver_match(odscheme_t *scheme, char *name)
|
|||
odscheme_route_t*
|
||||
od_schemeroute_match(odscheme_t *scheme, char *name)
|
||||
{
|
||||
odlist_t *i;
|
||||
od_list_t *i;
|
||||
od_listforeach(&scheme->routing_table, i) {
|
||||
odscheme_route_t *route;
|
||||
route = od_container_of(i, odscheme_route_t, link);
|
||||
|
@ -154,7 +154,7 @@ int od_schemevalidate(odscheme_t *scheme, od_log_t *log)
|
|||
od_error(log, "no servers are defined");
|
||||
return -1;
|
||||
}
|
||||
odlist_t *i;
|
||||
od_list_t *i;
|
||||
od_listforeach(&scheme->servers, i) {
|
||||
odscheme_server_t *server;
|
||||
server = od_container_of(i, odscheme_server_t, link);
|
||||
|
@ -222,7 +222,7 @@ void od_schemeprint(odscheme_t *scheme, od_log_t *log)
|
|||
od_log(log, " keepalive %d", scheme->keepalive);
|
||||
od_log(log, "");
|
||||
od_log(log, "servers");
|
||||
odlist_t *i;
|
||||
od_list_t *i;
|
||||
od_listforeach(&scheme->servers, i) {
|
||||
odscheme_server_t *server;
|
||||
server = od_container_of(i, odscheme_server_t, link);
|
||||
|
|
|
@ -24,12 +24,12 @@ typedef enum {
|
|||
} odrouting_t;
|
||||
|
||||
struct odscheme_server_t {
|
||||
int id;
|
||||
char *name;
|
||||
char *host;
|
||||
int port;
|
||||
int is_default;
|
||||
odlist_t link;
|
||||
int id;
|
||||
char *name;
|
||||
char *host;
|
||||
int port;
|
||||
int is_default;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
struct odscheme_route_t {
|
||||
|
@ -44,7 +44,7 @@ struct odscheme_route_t {
|
|||
int client_max;
|
||||
int pool_min;
|
||||
int pool_max;
|
||||
odlist_t link;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
struct odscheme_t {
|
||||
|
@ -68,12 +68,12 @@ struct odscheme_t {
|
|||
int workers;
|
||||
int client_max;
|
||||
/* servers */
|
||||
odlist_t servers;
|
||||
od_list_t servers;
|
||||
/* routing */
|
||||
char *routing;
|
||||
odrouting_t routing_mode;
|
||||
odscheme_route_t *routing_default;
|
||||
odlist_t routing_table;
|
||||
od_list_t routing_table;
|
||||
};
|
||||
|
||||
void od_schemeinit(odscheme_t*);
|
||||
|
|
|
@ -29,7 +29,7 @@ struct odserver_t {
|
|||
so_key_t key_client;
|
||||
void *route;
|
||||
void *pooler;
|
||||
odlist_t link;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
static inline void
|
||||
|
|
|
@ -44,7 +44,7 @@ void od_serverpool_init(odserver_pool_t *p)
|
|||
void od_serverpool_free(odserver_pool_t *p)
|
||||
{
|
||||
odserver_t *server;
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(&p->idle, i, n) {
|
||||
server = od_container_of(i, odserver_t, link);
|
||||
od_serverfree(server);
|
||||
|
@ -91,7 +91,7 @@ void od_serverpool_set(odserver_pool_t *p, odserver_t *server,
|
|||
p->count_active--;
|
||||
break;
|
||||
}
|
||||
odlist_t *target = NULL;
|
||||
od_list_t *target = NULL;
|
||||
switch (state) {
|
||||
case OD_SUNDEF:
|
||||
break;
|
||||
|
@ -126,7 +126,7 @@ void od_serverpool_set(odserver_pool_t *p, odserver_t *server,
|
|||
odserver_t*
|
||||
od_serverpool_pop(odserver_pool_t *p, odserver_state_t state)
|
||||
{
|
||||
odlist_t *target = NULL;
|
||||
od_list_t *target = NULL;
|
||||
switch (state) {
|
||||
case OD_SIDLE: target = &p->idle;
|
||||
break;
|
||||
|
@ -153,7 +153,7 @@ od_serverpool_foreach(odserver_pool_t *p, odserver_state_t state,
|
|||
odserver_pool_cb_t callback,
|
||||
void *arg)
|
||||
{
|
||||
odlist_t *target = NULL;
|
||||
od_list_t *target = NULL;
|
||||
switch (state) {
|
||||
case OD_SIDLE: target = &p->idle;
|
||||
break;
|
||||
|
@ -169,7 +169,7 @@ od_serverpool_foreach(odserver_pool_t *p, odserver_state_t state,
|
|||
break;
|
||||
}
|
||||
odserver_t *server;
|
||||
odlist_t *i, *n;
|
||||
od_list_t *i, *n;
|
||||
od_listforeach_safe(target, i, n) {
|
||||
server = od_container_of(i, odserver_t, link);
|
||||
int rc;
|
||||
|
|
|
@ -12,17 +12,17 @@ typedef struct odserver_pool_t odserver_pool_t;
|
|||
typedef int (*odserver_pool_cb_t)(odserver_t*, void*);
|
||||
|
||||
struct odserver_pool_t {
|
||||
odlist_t active;
|
||||
odlist_t connect;
|
||||
odlist_t reset;
|
||||
odlist_t expire;
|
||||
odlist_t idle;
|
||||
int count_active;
|
||||
int count_connect;
|
||||
int count_reset;
|
||||
int count_expire;
|
||||
int count_idle;
|
||||
odlist_t link;
|
||||
od_list_t active;
|
||||
od_list_t connect;
|
||||
od_list_t reset;
|
||||
od_list_t expire;
|
||||
od_list_t idle;
|
||||
int count_active;
|
||||
int count_connect;
|
||||
int count_reset;
|
||||
int count_expire;
|
||||
int count_idle;
|
||||
od_list_t link;
|
||||
};
|
||||
|
||||
void od_serverpool_init(odserver_pool_t*);
|
||||
|
|
Loading…
Reference in New Issue