[CLEANUP] proxy: rename a few proxy states (PR_STIDLE and PR_STRUN)
Those states have been replaced with PR_STFULL and PR_STREADY respectively,
as it is what matches them the best now. Also, two occurrences of PR_STIDLE
in peers.c have been removed as this did not provide any form of error recovery
anyway.
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 9bda578..e5d49ed 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -49,12 +49,14 @@
#include <types/stick_table.h>
/* values for proxy->state */
-#define PR_STNEW 0
-#define PR_STIDLE 1
-#define PR_STRUN 2
-#define PR_STSTOPPED 3
-#define PR_STPAUSED 4
-#define PR_STERROR 5
+enum {
+ PR_STNEW = 0, /* proxy has not been initialized yet */
+ PR_STREADY, /* proxy has been initialized and is ready */
+ PR_STFULL, /* frontend is full (maxconn reached) */
+ PR_STPAUSED, /* frontend is paused (during hot restart) */
+ PR_STSTOPPED, /* proxy is stopped (end of a restart) */
+ PR_STERROR, /* proxy experienced an unrecoverable error */
+};
/* values for proxy->mode */
#define PR_MODE_TCP 0
diff --git a/src/dumpstats.c b/src/dumpstats.c
index f3619a7..3ef2278 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -2050,8 +2050,8 @@
"",
U2H0(px->fe_counters.denied_req), U2H1(px->fe_counters.denied_resp),
U2H2(px->fe_counters.failed_req),
- px->state == PR_STRUN ? "OPEN" :
- px->state == PR_STIDLE ? "FULL" : "STOP");
+ px->state == PR_STREADY ? "OPEN" :
+ px->state == PR_STFULL ? "FULL" : "STOP");
} else {
chunk_printf(&msg,
/* pxid, name, queue cur, queue max, */
@@ -2081,8 +2081,8 @@
px->fe_counters.bytes_in, px->fe_counters.bytes_out,
px->fe_counters.denied_req, px->fe_counters.denied_resp,
px->fe_counters.failed_req,
- px->state == PR_STRUN ? "OPEN" :
- px->state == PR_STIDLE ? "FULL" : "STOP",
+ px->state == PR_STREADY ? "OPEN" :
+ px->state == PR_STFULL ? "FULL" : "STOP",
relative_pid, px->uuid, STATS_TYPE_FE,
read_freq_ctr(&px->fe_sess_per_sec),
px->fe_sps_lim, px->fe_counters.sps_max);
diff --git a/src/peers.c b/src/peers.c
index 47d9fe1..46a9178 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1114,7 +1114,6 @@
if ((s = pool_alloc2(pool2_session)) == NULL) { /* disable this proxy for a while */
Alert("out of memory in event_accept().\n");
- p->state = PR_STIDLE;
goto out_close;
}
@@ -1129,7 +1128,6 @@
*/
if ((t = task_new()) == NULL) { /* disable this proxy for a while */
Alert("out of memory in event_accept().\n");
- p->state = PR_STIDLE;
goto out_free_session;
}
diff --git a/src/proxy.c b/src/proxy.c
index db71021..a6c304f 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -407,7 +407,7 @@
* This function creates all proxy sockets. It should be done very early,
* typically before privileges are dropped. The sockets will be registered
* but not added to any fd_set, in order not to loose them across the fork().
- * The proxies also start in RUN state because they all have their listeners
+ * The proxies also start in READY state because they all have their listeners
* bound.
*
* Its return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL.
@@ -454,7 +454,7 @@
}
if (!pxerr) {
- curproxy->state = PR_STRUN;
+ curproxy->state = PR_STREADY;
send_log(curproxy, LOG_NOTICE, "Proxy %s started.\n", curproxy->id);
}
@@ -491,22 +491,21 @@
/* check the various reasons we may find to block the frontend */
if (unlikely(p->feconn >= p->maxconn)) {
- if (p->state == PR_STRUN)
- p->state = PR_STIDLE;
+ if (p->state == PR_STREADY)
+ p->state = PR_STFULL;
continue;
}
/* OK we have no reason to block, so let's unblock if we were blocking */
- if (p->state == PR_STIDLE)
- p->state = PR_STRUN;
+ if (p->state == PR_STFULL)
+ p->state = PR_STREADY;
if (p->fe_sps_lim &&
(wait = next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 1))) {
/* we're blocking because a limit was reached on the number of
* requests/s on the frontend. We want to re-check ASAP, which
* means in 1 ms before estimated expiration date, because the
- * timer will have settled down. Note that we may already be in
- * IDLE state here.
+ * timer will have settled down.
*/
*next = tick_first(*next, tick_add(now_ms, wait));
continue;
@@ -729,8 +728,7 @@
}
}
- /* maintain_proxies() will check if the proxy may remain enabled or not */
- p->state = PR_STRUN;
+ p->state = PR_STREADY;
if (fail)
pause_proxy(p);
}