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.
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[];
}
}
+ /* 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
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 */
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;
}