/* 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;
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;