[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.
This commit is contained in:
Willy Tarreau 2011-07-25 08:11:52 +02:00
parent f3f8c70bd6
commit 562515cac1
4 changed files with 20 additions and 22 deletions

View File

@ -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

View File

@ -2050,8 +2050,8 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
"",
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 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
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);

View File

@ -1114,7 +1114,6 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
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 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
*/
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;
}

View File

@ -407,7 +407,7 @@ int proxy_cfg_ensure_no_http(struct proxy *curproxy)
* 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 @@ int start_proxies(int verbose)
}
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 @@ void maintain_proxies(int *next)
/* 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 @@ void resume_proxies(void)
}
}
/* 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);
}