MINOR: proxy: disabled takes a stopping and a disabled state

This patch splits the disabled state of a proxy into a PR_DISABLED and a
PR_STOPPED state.

The first one is set when the proxy is disabled in the configuration
file, and the second one is set upon a stop_proxy().
This commit is contained in:
William Lallemand 2021-08-03 11:58:03 +02:00
parent fdc3faf654
commit 8e765b86fd
5 changed files with 11 additions and 6 deletions

View File

@ -200,6 +200,11 @@ enum PR_SRV_STATE_FILE {
*/
#define PR_RE_EARLY_ERROR 0x00010000 /* Retry if we failed at sending early data */
#define PR_RE_JUNK_REQUEST 0x00020000 /* We received an incomplete or garbage response */
/* disabled state */
#define PR_DISABLED 0x1 /* The proxy was disabled in the configuration (not at runtime) */
#define PR_STOPPED 0x2 /* The proxy was stopped */
struct stream;
struct http_snapshot {
@ -254,7 +259,7 @@ struct error_snapshot {
struct proxy {
enum obj_type obj_type; /* object type == OBJ_TYPE_PROXY */
char disabled; /* non-zero if disabled or shutdown */
char disabled; /* bit field PR_DISABLED | PR_STOPPED */
enum pr_mode mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP, ... */
char cap; /* supported capabilities (PR_CAP_*) */
unsigned int maxconn; /* max # of active streams on the frontend */

View File

@ -593,7 +593,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
else if (strcmp(args[0], "disabled") == 0) { /* disables this proxy */
if (alertif_too_many_args(0, file, linenum, args, &err_code))
goto out;
curproxy->disabled = 1;
curproxy->disabled = PR_DISABLED;
}
else if (strcmp(args[0], "enabled") == 0) { /* enables this proxy (used to revert a disabled default) */
if (alertif_too_many_args(0, file, linenum, args, &err_code))

View File

@ -1018,7 +1018,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
stktables_list = t;
}
else if (strcmp(args[0], "disabled") == 0) { /* disables this peers section */
curpeers->disabled = 1;
curpeers->disabled = PR_DISABLED;
}
else if (strcmp(args[0], "enabled") == 0) { /* enables this peers section (used to revert a disabled default) */
curpeers->disabled = 0;

View File

@ -443,7 +443,7 @@ void mworker_cleanlisteners()
}
/* if the proxy shouldn't be in the master, we stop it */
if (!listen_in_master)
curproxy->disabled = 1;
curproxy->disabled = PR_DISABLED;
}
}

View File

@ -1801,7 +1801,7 @@ void proxy_cond_disable(struct proxy *p)
if (p->li_ready + p->li_paused > 0)
return;
p->disabled = 1;
p->disabled = PR_STOPPED;
/* Note: syslog proxies use their own loggers so while it's somewhat OK
* to report them being stopped as a warning, we must not spam their log
@ -2050,7 +2050,7 @@ void stop_proxy(struct proxy *p)
if (!p->disabled && !p->li_ready) {
/* might be just a backend */
p->disabled = 1;
p->disabled |= PR_STOPPED;
}
HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &p->lock);