mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-29 18:18:59 -04:00
MEDIUM: proxy: implement backend deletion
This patch finalizes "del backend" handler by implementing the proper proxy deletion. After ensuring backend deletion can be performed, several steps are executed. First, any watcher elements are updated to point on the next proxy instance. The backend is then removed from ID and name global trees and is finally detached from proxies_list. Once the backend instance is removed from proxies_list, the backend cannot be found by new elements. Thread isolation is lifted and proxy_drop() is called, which will purge the proxy if its refcount is null. Thanks to recently introduced PROXIES_DEL_LOCK, proxy_drop() is thread safe.
This commit is contained in:
parent
6145f52d9c
commit
712055f2f8
1 changed files with 23 additions and 1 deletions
24
src/proxy.c
24
src/proxy.c
|
|
@ -5098,7 +5098,8 @@ int be_check_for_deletion(const char *bename, struct proxy **pb, const char **pm
|
|||
/* Handler for "delete backend". Runs under thread isolation. Always returns 1. */
|
||||
static int cli_parse_delete_backend(char **args, char *payload, struct appctx *appctx, void *private)
|
||||
{
|
||||
struct proxy *px;
|
||||
struct watcher *px_watch;
|
||||
struct proxy *px, *prev;
|
||||
const char *msg;
|
||||
char *be_name;
|
||||
int ret;
|
||||
|
|
@ -5120,11 +5121,32 @@ static int cli_parse_delete_backend(char **args, char *payload, struct appctx *a
|
|||
goto out;
|
||||
}
|
||||
|
||||
while (!MT_LIST_ISEMPTY(&px->watcher_list)) {
|
||||
px_watch = MT_LIST_NEXT(&px->watcher_list, struct watcher *, el);
|
||||
watcher_next(px_watch, px->next);
|
||||
}
|
||||
|
||||
ceb32_item_delete(&used_proxy_id, conf.uuid_node, uuid, px);
|
||||
cebis_item_delete(&proxy_by_name, conf.name_node, id, px);
|
||||
|
||||
/* Detach backend from global proxies_list. */
|
||||
if (proxies_list == px) {
|
||||
proxies_list = px->next;
|
||||
}
|
||||
else {
|
||||
for (prev = proxies_list->next; prev && prev->next != px; prev = prev->next)
|
||||
;
|
||||
BUG_ON(!prev); /* Proxy instance not found in global list ? */
|
||||
prev->next = px->next;
|
||||
}
|
||||
|
||||
px->flags |= PR_FL_DELETED;
|
||||
|
||||
thread_release();
|
||||
|
||||
ha_notice("Backend deleted.\n");
|
||||
proxy_drop(px);
|
||||
|
||||
cli_umsg(appctx, LOG_INFO);
|
||||
return 1;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue