SHOW_SRV_LIST,
} state;
+ struct watcher px_watch; /* watcher to automatically update px on backend deletion */
struct watcher srv_watch; /* watcher to automatically update sv on server deletion */
};
struct proxy *px;
ctx->show_conn = *args[2] == 'c'; // "conn" vs "state"
+
+ watcher_init(&ctx->px_watch, &ctx->px, offsetof(struct proxy, watcher_list));
watcher_init(&ctx->srv_watch, &ctx->sv, offsetof(struct server, watcher_list));
/* check if a backend name has been provided */
if (!px)
return cli_err(appctx, "Can't find backend.\n");
- ctx->px = px;
+ watcher_attach(&ctx->px_watch, px);
ctx->only_pxid = px->uuid;
}
return 0;
ctx->state = SHOW_SRV_LIST;
if (!ctx->px)
- ctx->px = proxies_list;
+ watcher_attach(&ctx->px_watch, proxies_list);
}
- for (; ctx->px != NULL; ctx->px = curproxy->next) {
+ for (; ctx->px; watcher_next(&ctx->px_watch, ctx->px->next)) {
curproxy = ctx->px;
/* servers are only in backends */
if ((curproxy->cap & PR_CAP_BE) && !(curproxy->cap & PR_CAP_INT)) {
return 0;
}
/* only the selected proxy is dumped */
- if (ctx->only_pxid)
+ if (ctx->only_pxid) {
+ watcher_detach(&ctx->px_watch);
break;
+ }
}
return 1;