mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 12:41:00 +02:00
MINOR: proxy: assign dynamic proxy ID
Implement proxy ID generation for dynamic backends. This is performed through the already function existing proxy_get_next_id(). As an optimization, lookup will performed starting from a global variable <dynpx_next_id>. It is initialized to the greatest ID assigned after parsing, and updated each time a backend instance is created. When backend deletion will be implemented, it could be lowered to the newly available slot.
This commit is contained in:
parent
3115eb82a6
commit
5753c14e84
@ -41,6 +41,8 @@ extern unsigned int error_snapshot_id; /* global ID assigned to each error then
|
||||
extern struct ceb_root *proxy_by_name; /* tree of proxies sorted by name */
|
||||
extern struct list defaults_list; /* all defaults proxies list */
|
||||
|
||||
extern unsigned int dynpx_next_id;
|
||||
|
||||
extern const struct cfg_opt cfg_opts[];
|
||||
extern const struct cfg_opt cfg_opts2[];
|
||||
extern const struct cfg_opt cfg_opts3[];
|
||||
|
||||
@ -2428,6 +2428,9 @@ init_proxies_list_stage1:
|
||||
}
|
||||
}
|
||||
|
||||
/* Dynamic proxies IDs will never be lowered than this value. */
|
||||
dynpx_next_id = next_pxid;
|
||||
|
||||
/*
|
||||
* We have just initialized the main proxies list
|
||||
* we must also configure the log-forward proxies list
|
||||
|
||||
10
src/proxy.c
10
src/proxy.c
@ -77,6 +77,8 @@ struct ceb_root *defproxy_by_name = NULL; /* tree of default proxies sorted by n
|
||||
struct list defaults_list = LIST_HEAD_INIT(defaults_list); /* list of all defaults proxies */
|
||||
unsigned int error_snapshot_id = 0; /* global ID assigned to each error then incremented */
|
||||
|
||||
unsigned int dynpx_next_id = 0; /* lowest ID assigned to dynamic proxies */
|
||||
|
||||
/* CLI context used during "show servers {state|conn}" */
|
||||
struct show_srv_ctx {
|
||||
struct proxy *px; /* current proxy to dump or NULL */
|
||||
@ -4916,6 +4918,14 @@ static int cli_parse_add_backend(char **args, char *payload, struct appctx *appc
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Assign automatically proxy ID. */
|
||||
px->uuid = proxy_get_next_id(dynpx_next_id);
|
||||
if (!px->uuid) {
|
||||
memprintf(&msg, "no spare proxy ID available");
|
||||
goto err;
|
||||
}
|
||||
dynpx_next_id = px->uuid;
|
||||
|
||||
if (!proxies_list) {
|
||||
proxies_list->next = px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user