]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: remove the SRV_DRAIN flag which can always be deduced
authorWilly Tarreau <w@1wt.eu>
Tue, 13 May 2014 20:08:20 +0000 (22:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 May 2014 20:18:13 +0000 (22:18 +0200)
This flag is only a copy of (srv->uweight == 0), so better get rid of
it to reduce some of the confusion that remains in the code, and use
a simple function to return this state based on this weight instead.

include/proto/server.h
include/types/server.h
src/checks.c
src/dumpstats.c
src/server.c

index f030962a3543f49a3bfc8332170cf7bb74463a85..0433ac0d14c93266388b9cc7aa00e5e9fe71ef60 100644 (file)
@@ -96,16 +96,12 @@ const char *server_parse_weight_change_request(struct server *sv,
                                               const char *weight_str);
 
 /*
- * Update the server's drain state to reflect its user-weight.  This is not
- * done immediately to allow a discrepancy between the server's user-weight
- * and drains state to control logging of changes in the drain state.
+ * Return true if the server has a zero user-weight, meaning it's in draining
+ * mode (ie: not taking new non-persistent connections).
  */
-static inline void set_server_drain_state(struct server *s)
+static inline int server_is_draining(const struct server *s)
 {
-       if (!s->uweight)
-               s->state |= SRV_DRAIN;
-       else
-               s->state &= ~SRV_DRAIN;
+       return !s->uweight;
 }
 /*
  * Local variables:
index 7a977e3e79c71b51fc87a5c55838776f3bbb54e6..0897f9a8b72f51583ee4ad73f07760c848064806 100644 (file)
@@ -52,8 +52,7 @@
 #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 */
-#define SRV_DRAIN      0x0100  /* this server has been requested to drain its connections */
-/* unused: 0x0200, 0x0400, 0x0800 */
+/* unused: 0x0100, 0x0200, 0x0400, 0x0800 */
 #define SRV_NON_STICK  0x1000  /* never add connections allocated to this server to a stick table */
 
 /* configured server options for send-proxy (server->pp_opts) */
index b4d11c1ea89b48721811aa303ec6926ec0efae36..2fbda11822fe59135e2bd35aeb887976e0d188e3 100644 (file)
@@ -1214,7 +1214,6 @@ static void event_srv_chk_r(struct connection *conn)
                }
 
                set_server_check_status(check, status, desc);
-               set_server_drain_state(check->server);
                break;
        }
 
index eae736c53f11d5cdfa395239868d7680df2988ce..13843f893b7260d30cbabc503dc9c21b40264581 100644 (file)
@@ -1355,12 +1355,6 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                                return 1;
 
                        warning = server_parse_weight_change_request(sv, args[3]);
-                       /*
-                        * The user-weight may now be zero and thus
-                        * the server considered to be draining.
-                        * Update the server's drain state as necessary.
-                        */
-                       set_server_drain_state(sv);
                        if (warning) {
                                appctx->ctx.cli.msg = warning;
                                appctx->st0 = STAT_CLI_PRINT;
@@ -3633,7 +3627,7 @@ static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy
                                else
                                        sv_state = 2; /* going down */
 
-                               if (svs->state & SRV_DRAIN)
+                               if (server_is_draining(svs))
                                        sv_state += 4;
                                else if (svs->state & SRV_GOINGDOWN)
                                        sv_state += 2;
@@ -4291,7 +4285,6 @@ static int stats_process_http_post(struct stream_interface *si)
                                                        sv->uweight = 0;
 
                                                server_recalc_eweight(sv);
-                                               set_server_drain_state(sv);
 
                                                altered_servers++;
                                                total_servers++;
index 190168641f24766b45690c20328b124ba5098a6b..a903e84c2a6a311377db4c38c546dbfff9be2b74 100644 (file)
@@ -1026,9 +1026,6 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
                        }
                }
 
-               /* Set initial drain state using now-configured weight */
-               set_server_drain_state(newsrv);
-
                if (do_check) {
                        int ret;