From: Willy Tarreau Date: Thu, 24 Sep 2020 05:44:34 +0000 (+0200) Subject: MEDIUM: proxy: remove the PR_STERROR state X-Git-Tag: v2.3-dev6~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a17c91b37f9cf421366e5fbda504981916457721;p=thirdparty%2Fhaproxy.git MEDIUM: proxy: remove the PR_STERROR state This state is only set when a pause() fails but isn't even set when a resume() fails. And we cannot recover from this state. Instead, let's just count remaining ready listeners to decide to emit an error or not. It's more accurate and will better support new attempts if needed. --- diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index f0c61b3b7a..f2fdf01d51 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -48,7 +48,6 @@ enum pr_state { PR_STREADY, /* proxy has been initialized and is ready */ PR_STPAUSED, /* frontend is paused (during hot restart) */ PR_STSTOPPED, /* proxy is stopped (end of a restart) */ - PR_STERROR, /* proxy experienced an unrecoverable error */ } __attribute__((packed)); /* values for proxy->mode */ diff --git a/src/proxy.c b/src/proxy.c index d3c207e717..06fb0d9f6f 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1281,28 +1281,24 @@ void soft_stop(void) /* Temporarily disables listening on all of the proxy's listeners. Upon - * success, the proxy enters the PR_PAUSED state. If disabling at least one - * listener returns an error, then the proxy state is set to PR_STERROR - * because we don't know how to resume from this. The function returns 0 + * success, the proxy enters the PR_PAUSED state. The function returns 0 * if it fails, or non-zero on success. */ int pause_proxy(struct proxy *p) { struct listener *l; - if (!(p->cap & PR_CAP_FE) || p->state == PR_STERROR || + if (!(p->cap & PR_CAP_FE) || p->state == PR_STSTOPPED || p->state == PR_STPAUSED) return 1; ha_warning("Pausing %s %s.\n", proxy_cap_str(p->cap), p->id); send_log(p, LOG_WARNING, "Pausing %s %s.\n", proxy_cap_str(p->cap), p->id); - list_for_each_entry(l, &p->conf.listeners, by_fe) { - if (!pause_listener(l)) - p->state = PR_STERROR; - } + list_for_each_entry(l, &p->conf.listeners, by_fe) + pause_listener(l); - if (p->state == PR_STERROR) { + if (p->li_ready) { ha_warning("%s %s failed to enter pause mode.\n", proxy_cap_str(p->cap), p->id); send_log(p, LOG_WARNING, "%s %s failed to enter pause mode.\n", proxy_cap_str(p->cap), p->id); return 0;