MINOR: server: remove the SRV_DRAIN flag which can always be deduced

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.
This commit is contained in:
Willy Tarreau 2014-05-13 22:08:20 +02:00
parent bef1b32c4e
commit 02615f9b16
5 changed files with 6 additions and 22 deletions

View 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:

View 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) */

View 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;
}

View 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++;

View 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;