]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: use check->state instead of srv->state & SRV_CHECKED
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Dec 2013 19:36:34 +0000 (20:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Dec 2013 15:02:19 +0000 (16:02 +0100)
Having the check state partially stored in the server doesn't help.
Some functions such as srv_getinter() rely on the server being checked
to decide what check frequency to use, instead of relying on the check
being configured. So let's get rid of SRV_CHECKED and SRV_AGENT_CHECKED
and only use the check's states instead.

include/types/server.h
src/backend.c
src/cfgparse.c
src/checks.c
src/dumpstats.c
src/server.c

index 7775369d6154f4af8a445e5c94a53a203f0b316f..54ab8133c71b4898b6fa88437c19750411de0a34 100644 (file)
@@ -48,7 +48,7 @@
 #define SRV_BACKUP     0x0002  /* this server is a backup server */
 #define SRV_MAPPORTS   0x0004  /* this server uses mapped ports */
 /* unused: 0x0008 */
-#define SRV_CHECKED    0x0010  /* this server needs to be checked */
+/* unused: 0x0010 */
 #define SRV_GOINGDOWN  0x0020  /* this server says that it's going down (404) */
 #define SRV_WARMINGUP  0x0040  /* this server is warming up after a failure */
 #define SRV_MAINTAIN   0x0080  /* this server is in maintenance mode */
@@ -56,9 +56,6 @@
 /* unused: 0x0200, 0x0400 */
 #define SRV_SEND_PROXY 0x0800  /* this server talks the PROXY protocol */
 #define SRV_NON_STICK  0x1000  /* never add connections allocated to this server to a stick table */
-#define SRV_AGENT_CHECKED  0x2000  /* this server needs to be checked using an agent check.
-                                   * This is run independently of the main check whose
-                                   * presence is indicated by the SRV_CHECKED flag */
 
 /* function which act on servers need to return various errors */
 #define SRV_STATUS_OK       0   /* everything is OK. */
index 55debefafd1b91265e36c8c574ca85f43160585e..c680777435e132a99125fe1e90f1e6f02eca82a9 100644 (file)
@@ -1443,7 +1443,7 @@ smp_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, unsigned int
        smp->flags = SMP_F_VOL_TEST;
        smp->type = SMP_T_BOOL;
        if (!(srv->state & SRV_MAINTAIN) &&
-           (!(srv->state & SRV_CHECKED) || (srv->state & SRV_RUNNING)))
+           (!(srv->check.state & CHK_ST_CONFIGURED) || (srv->state & SRV_RUNNING)))
                smp->data.uint = 1;
        else
                smp->data.uint = 0;
index b67594114be97301d8ea253e804fd29367e78829..98d4c678e245ee8b1bd3ed14feb01042dd9cfd46 100644 (file)
@@ -5124,7 +5124,6 @@ stats_error_parsing:
                        }
 
                        newsrv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
-                       newsrv->state |= SRV_CHECKED;
                }
 
                if (do_agent) {
@@ -5147,7 +5146,6 @@ stats_error_parsing:
                        }
 
                        newsrv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
-                       newsrv->state |= SRV_AGENT_CHECKED;
                }
 
                if (!defsrv) {
@@ -7018,7 +7016,7 @@ out_uri_auth_compat:
                                        goto next_srv;
                                }
 
-                               if (!(srv->state & SRV_CHECKED)) {
+                               if (!(srv->check.state & CHK_ST_CONFIGURED)) {
                                        Alert("config : %s '%s', server '%s': unable to use %s/%s for "
                                                "tracking as it does not have checks enabled.\n",
                                                proxy_type_str(curproxy), curproxy->id,
index 49bb411955f876090d1a3d34abdf834910870d0e..ec057812f4910c6e5fd449921c72b7fa09f09dc9 100644 (file)
@@ -736,8 +736,8 @@ static int httpchk_build_status_header(struct server *s, char *buffer)
        memcpy(buffer + hlen, "X-Haproxy-Server-State: ", 24);
        hlen += 24;
 
-       if (!(s->state & SRV_CHECKED))
-               sv_state = 6; /* should obviously never happen */
+       if (!(s->check.state & CHK_ST_ENABLED))
+               sv_state = 6;
        else if (s->state & SRV_RUNNING) {
                if (s->check.health == s->check.rise + s->check.fall - 1)
                        sv_state = 3; /* UP */
@@ -1506,7 +1506,7 @@ static struct task *process_chk(struct task *t)
                 * stopped, the server should not be checked or the check
                 * is disabled.
                 */
-               if (!(s->state & SRV_CHECKED) ||
+               if (!(s->check.state & CHK_ST_ENABLED) ||
                    s->proxy->state == PR_STSTOPPED ||
                    (s->state & SRV_MAINTAIN) ||
                    !(check->state & CHK_ST_ENABLED))
@@ -1764,7 +1764,7 @@ int start_checks() {
                                t->expire = TICK_ETERNITY;
                        }
 
-                       if (!(s->state & SRV_CHECKED))
+                       if (!(s->check.state & CHK_ST_CONFIGURED))
                                continue;
 
                        if ((srv_getinter(&s->check) >= SRV_CHK_INTER_THRES) &&
@@ -1788,14 +1788,14 @@ int start_checks() {
        for (px = proxy; px; px = px->next) {
                for (s = px->srv; s; s = s->next) {
                        /* A task for the main check */
-                       if (s->state & SRV_CHECKED) {
+                       if (s->check.state & CHK_ST_CONFIGURED) {
                                if (!start_check_task(&s->check, mininter, nbcheck, srvpos))
                                        return -1;
                                srvpos++;
                        }
 
                        /* A task for a auxiliary agent check */
-                       if (s->state & SRV_AGENT_CHECKED) {
+                       if (s->agent.state & CHK_ST_CONFIGURED) {
                                if (!start_check_task(&s->agent, mininter, nbcheck, srvpos)) {
                                        return -1;
                                }
index 350b11103525056a6bf23e74329d6ceccebbfc92..454795824ff3e37bf53da45517145abb7ec5e3c5 100644 (file)
@@ -2716,7 +2716,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
                        chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1));
                        chunk_appendf(&trash, "MAINT(via)");
                }
-               else if (ref->state & SRV_CHECKED) {
+               else if (ref->check.state & CHK_ST_ENABLED) {
                        chunk_appendf(&trash, "%s ", human_time(now.tv_sec - ref->last_change, 1));
                        chunk_appendf(&trash,
                                      srv_hlt_st[state],
@@ -2724,7 +2724,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
                                      (ref->state & SRV_RUNNING) ? (ref->check.fall) : (ref->check.rise));
                }
 
-               if (sv->state & SRV_CHECKED) {
+               if (sv->check.state & CHK_ST_ENABLED) {
                        chunk_appendf(&trash,
                                      "</td><td class=ac><u> %s%s",
                                      (sv->check.state & CHK_ST_INPROGRESS) ? "* " : "",
@@ -2759,7 +2759,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
                              (sv->state & SRV_BACKUP) ? "Y" : "-");
 
                /* check failures: unique, fatal, down time */
-               if (sv->state & SRV_CHECKED) {
+               if (sv->check.state & CHK_ST_ENABLED) {
                        chunk_appendf(&trash, "<td><u>%lld", ref->counters.failed_checks);
 
                        if (ref->observe)
@@ -2848,7 +2848,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
                              (sv->state & SRV_BACKUP) ? 1 : 0);
 
                /* check failures: unique, fatal; last change, total downtime */
-               if (sv->state & SRV_CHECKED)
+               if (sv->check.state & CHK_ST_ENABLED)
                        chunk_appendf(&trash,
                                      "%lld,%lld,%d,%d,",
                                      sv->counters.failed_checks, sv->counters.down_trans,
@@ -2885,7 +2885,7 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in
                              read_freq_ctr(&sv->sess_per_sec),
                              sv->counters.sps_max);
 
-               if (sv->state & SRV_CHECKED) {
+               if (sv->check.state & CHK_ST_ENABLED) {
                        /* check_status */
                        chunk_appendf(&trash, "%s,", get_check_status_info(sv->check.status));
 
@@ -3407,7 +3407,7 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
                                svs = sv;
 
                        /* FIXME: produce some small strings for "UP/DOWN x/y &#xxxx;" */
-                       if (!(svs->state & SRV_CHECKED))
+                       if (!(svs->check.state & CHK_ST_ENABLED))
                                sv_state = 8;
                        else if (svs->state & SRV_RUNNING) {
                                if (svs->check.health == svs->check.rise + svs->check.fall - 1)
index a316daa5c7df312ff5fb29c81410d5688bb94390..d91c726a4590a7e9e51c7baf813297e90db563b3 100644 (file)
@@ -34,7 +34,7 @@ int srv_getinter(const struct check *check)
 {
        const struct server *s = check->server;
 
-       if ((s->state & SRV_CHECKED) && (check->health == check->rise + check->fall - 1))
+       if ((check->state & CHK_ST_CONFIGURED) && (check->health == check->rise + check->fall - 1))
                return check->inter;
 
        if (!(s->state & SRV_RUNNING) && check->health == 0)