mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 13:21:29 +02:00
MINOR: proxy: add proxy_get_next_id() to find next free proxy ID
This was previously achieved via the generic get_next_id() but we'll soon get rid of generic ID trees so let's have a dedicated proxy_get_next_id().
This commit is contained in:
parent
f4059ea42f
commit
b2402d67b7
@ -57,6 +57,7 @@ void free_proxy(struct proxy *p);
|
||||
const char *proxy_cap_str(int cap);
|
||||
const char *proxy_mode_str(int mode);
|
||||
const char *proxy_find_best_option(const char *word, const char **extra);
|
||||
uint proxy_get_next_id(uint from);
|
||||
void proxy_store_name(struct proxy *px);
|
||||
struct proxy *proxy_find_by_id(int id, int cap, int table);
|
||||
struct proxy *proxy_find_by_name(const char *name, int cap, int table);
|
||||
|
@ -2850,7 +2850,7 @@ init_proxies_list_stage1:
|
||||
* build or config options and we don't want them to
|
||||
* possibly reuse existing IDs.
|
||||
*/
|
||||
next_pxid = get_next_id(&used_proxy_id, next_pxid);
|
||||
next_pxid = proxy_get_next_id(next_pxid);
|
||||
curproxy->conf.id.key = curproxy->uuid = next_pxid;
|
||||
eb32_insert(&used_proxy_id, &curproxy->conf.id);
|
||||
}
|
||||
|
17
src/proxy.c
17
src/proxy.c
@ -538,6 +538,23 @@ const char *proxy_find_best_option(const char *word, const char **extra)
|
||||
return best_ptr;
|
||||
}
|
||||
|
||||
/* This function returns the first unused proxy ID greater than or equal to
|
||||
* <from> in used_proxy_id. Zero is returned if no spare one is found (should
|
||||
* never happen).
|
||||
*/
|
||||
uint proxy_get_next_id(uint from)
|
||||
{
|
||||
struct eb32_node *used;
|
||||
|
||||
do {
|
||||
used = eb32_lookup_ge(&used_proxy_id, from);
|
||||
if (!used || used->key > from)
|
||||
return from; /* available */
|
||||
from++;
|
||||
} while (from);
|
||||
return from;
|
||||
}
|
||||
|
||||
/* This function parses a "timeout" statement in a proxy section. It returns
|
||||
* -1 if there is any error, 1 for a warning, otherwise zero. If it does not
|
||||
* return zero, it will write an error or warning message into a preallocated
|
||||
|
Loading…
x
Reference in New Issue
Block a user