]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] proxy: rename a few proxy states (PR_STIDLE and PR_STRUN)
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Jul 2011 06:11:52 +0000 (08:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Jul 2011 06:11:52 +0000 (08:11 +0200)
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.

include/types/proxy.h
src/dumpstats.c
src/peers.c
src/proxy.c

index 9bda57838a57e54ebbae9a2ec78645e331056d93..e5d49edc4f495fc18cb8366f5fa93751e3ba394c 100644 (file)
 #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
index f3619a7c053e04c419d7b9e983c8de0f4e3be1e5..3ef2278c1ac5cb3b1d4536504f86572fc827b4ea 100644 (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);
index 47d9fe13d893b54ee84691e94b6817f881d1c15f..46a917843bce209893ff6559a94c1f10d219a197 100644 (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;
        }
 
index db710217689550ecf6721f6da2b5e5f0da52a716..a6c304f3e0af6cfe664cdc0f82bd18238855e312 100644 (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);
                }