enum obj_type obj_type; /* object type = OBJ_TYPE_LISTENER */
enum li_state state; /* state: NEW, INIT, ASSIGNED, LISTEN, READY, FULL */
uint16_t flags; /* listener flags: LI_F_* */
- int luid; /* listener universally unique ID, used for SNMP */
+ int luid; /* listener universally unique ID, used for SNMP, indexed by <luid_node> below */
int nbconn; /* current number of connections on this listener */
unsigned long thr_idx; /* thread indexes for queue distribution (see listener_accept()) */
__decl_thread(HA_RWLOCK_T lock);
struct list by_bind; /* chaining in bind_conf's list of listeners */
struct bind_conf *bind_conf; /* "bind" line settings, include SSL settings among other things */
struct receiver rx; /* network receiver parts */
- struct {
- struct eb32_node id; /* place in the tree of used IDs */
- } conf; /* config information */
-
+ struct ceb_node luid_node; /* place in the tree of used IDs, indexes <luid> above */
struct guid_node guid; /* GUID global tree node */
struct li_per_thread *per_thr; /* per-thread fields (one per thread in the group) */
#include <stdlib.h>
#include <string.h>
-#include <import/eb32tree.h>
+#include <import/ceb32_tree.h>
#include <haproxy/api.h>
#include <haproxy/listener-t.h>
/* index listener <li>'s id into proxy <px>'s used_listener_id */
static inline void listener_index_id(struct proxy *px, struct listener *li)
{
- eb32_insert(&px->conf.used_listener_id, &li->conf.id);
+ ceb32_item_insert(&px->conf.used_listener_id, luid_node, luid, li);
}
static inline uint accept_queue_ring_len(const struct accept_queue_ring *ring)
*/
uint listener_get_next_id(const struct proxy *px, uint from)
{
- const struct eb32_node *used;
+ const struct listener *li;
do {
- used = eb32_lookup_ge((struct eb_root*)&px->conf.used_listener_id, from);
- if (!used || used->key > from)
+ li = ceb32_item_lookup_ge(&px->conf.used_listener_id, luid_node, luid, from, struct listener);
+ if (!li || li->luid > from)
return from; /* available */
from++;
} while (from);
return cfgerr;
}
/* assign the ID to the first one only */
- new_li->luid = new_li->conf.id.key = tmp_li->luid;
+ ceb32_item_delete(&fe->conf.used_listener_id, luid_node, luid, tmp_li);
+ new_li->luid = tmp_li->luid;
tmp_li->luid = 0;
- eb32_delete(&tmp_li->conf.id);
if (new_li->luid)
listener_index_id(fe, new_li);
new_li = tmp_li;
return cfgerr;
}
/* assign the ID to the first one only */
- new_li->luid = new_li->conf.id.key = li->luid;
+ ceb32_item_delete(&fe->conf.used_listener_id, luid_node, luid, li);
+ new_li->luid = li->luid;
li->luid = 0;
- eb32_delete(&li->conf.id);
if (new_li->luid)
listener_index_id(fe, new_li);
}
/* parse the "id" bind keyword */
static int bind_parse_id(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
- struct eb32_node *node;
struct listener *l, *new;
char *error;
memprintf(err, "'%s' : expects an integer argument, found '%s'", args[cur_arg], args[cur_arg + 1]);
return ERR_ALERT | ERR_FATAL;
}
- new->conf.id.key = new->luid;
if (new->luid <= 0) {
memprintf(err, "'%s' : custom id has to be > 0", args[cur_arg]);
return ERR_ALERT | ERR_FATAL;
}
- node = eb32_lookup(&px->conf.used_listener_id, new->luid);
- if (node) {
- l = container_of(node, struct listener, conf.id);
+ l = ceb32_item_lookup(&px->conf.used_listener_id, luid_node, luid, new->luid, struct listener);
+ if (l) {
memprintf(err, "'%s' : custom id %d already used at %s:%d ('bind %s')",
args[cur_arg], l->luid, l->bind_conf->file, l->bind_conf->line,
l->bind_conf->arg);