From 44267700139fe7fb28f68220d9ee8cc436ffe3e3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 28 Oct 2011 15:35:33 +0200 Subject: CLEANUP: rename possibly confusing struct field "tracked" When reading the code, the "tracked" member of a server makes one think the server is tracked while it's the opposite, it's a pointer to the server being tracked. This is particularly true in constructs such as : if (srv->tracked) { Since it's the second time I get caught misunderstanding it, let's rename it to "track" to avoid the confusion. --- include/types/server.h | 2 +- src/cfgparse.c | 2 +- src/checks.c | 16 ++++++++-------- src/dumpstats.c | 14 +++++++------- src/queue.c | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/types/server.h b/include/types/server.h index 6b35c32..4cbd21c 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -110,7 +110,7 @@ struct server { char *iface_name; /* bind interface name or NULL */ struct port_range *sport_range; /* optional per-server TCP source ports */ - struct server *tracknext, *tracked; /* next server in a tracking list, tracked server */ + struct server *tracknext, *track; /* next server in a tracking list, tracked server */ char *trackit; /* temporary variable to make assignment deferrable */ struct sockaddr_storage check_addr; /* the address to check, if different from */ short check_port; /* the port to use for the health checks */ diff --git a/src/cfgparse.c b/src/cfgparse.c index bf76185..a320bfb 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -6235,7 +6235,7 @@ out_uri_auth_compat: goto next_srv; } - newsrv->tracked = srv; + newsrv->track = srv; newsrv->tracknext = srv->tracknext; srv->tracknext = newsrv; diff --git a/src/checks.c b/src/checks.c index f0338d7..67c2270 100644 --- a/src/checks.c +++ b/src/checks.c @@ -149,9 +149,9 @@ const char *get_analyze_status(short analyze_status) { static void server_status_printf(struct chunk *msg, struct server *s, unsigned options, int xferred) { - if (s->tracked) + if (s->track) chunk_printf(msg, " via %s/%s", - s->tracked->proxy->id, s->tracked->id); + s->track->proxy->id, s->track->id); if (options & SSP_O_HCHK) { chunk_printf(msg, ", reason: %s", get_check_status_description(s->check_status)); @@ -384,7 +384,7 @@ void set_server_down(struct server *s) s->health = s->rise; } - if (s->health == s->rise || s->tracked) { + if (s->health == s->rise || s->track) { int srv_was_paused = s->state & SRV_GOINGDOWN; int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act; @@ -413,7 +413,7 @@ void set_server_down(struct server *s) s->proxy->id, s->id); server_status_printf(&msg, s, - ((!s->tracked && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), + ((!s->track && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), xferred); } Warning("%s.\n", trash); @@ -449,7 +449,7 @@ void set_server_up(struct server *s) { s->health = s->rise; } - if (s->health == s->rise || s->tracked) { + if (s->health == s->rise || s->track) { if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) { if (s->proxy->last_change < now.tv_sec) // ignore negative times s->proxy->down_time += now.tv_sec - s->proxy->last_change; @@ -492,7 +492,7 @@ void set_server_up(struct server *s) { s->proxy->id, s->id); server_status_printf(&msg, s, - ((!s->tracked && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), + ((!s->track && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), xferred); } @@ -536,7 +536,7 @@ static void set_server_disabled(struct server *s) { s->proxy->id, s->id); server_status_printf(&msg, s, - ((!s->tracked && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), + ((!s->track && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), xferred); Warning("%s.\n", trash); @@ -572,7 +572,7 @@ static void set_server_enabled(struct server *s) { s->proxy->id, s->id); server_status_printf(&msg, s, - ((!s->tracked && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), + ((!s->track && !(s->proxy->options2 & PR_O2_LOGHCHKS))?SSP_O_HCHK:0), xferred); Warning("%s.\n", trash); diff --git a/src/dumpstats.c b/src/dumpstats.c index a15b15b..f4d5c33 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -1159,11 +1159,11 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) if (sv->state & SRV_MAINTAIN) { /* The server is really in maintenance, we can change the server state */ - if (sv->tracked) { + if (sv->track) { /* If this server tracks the status of another one, * we must restore the good status. */ - if (sv->tracked->state & SRV_RUNNING) { + if (sv->track->state & SRV_RUNNING) { set_server_up(sv); sv->health = sv->rise; /* up, but will fall down at first failure */ } else { @@ -2120,7 +2120,7 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc { struct session *s = si->applet.private; struct buffer *rep = si->ib; - struct server *sv, *svs; /* server and server-state, server-state=server or server->tracked */ + struct server *sv, *svs; /* server and server-state, server-state=server or server->track */ struct listener *l; struct chunk msg; @@ -2541,8 +2541,8 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc continue; } - if (sv->tracked) - svs = sv->tracked; + if (sv->track) + svs = sv->track; else svs = sv; @@ -2866,9 +2866,9 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc chunk_printf(&msg, ",%lld,", sv->counters.cum_lbconn); /* tracked */ - if (sv->tracked) + if (sv->track) chunk_printf(&msg, "%s/%s,", - sv->tracked->proxy->id, sv->tracked->id); + sv->track->proxy->id, sv->track->id); else chunk_printf(&msg, ","); diff --git a/src/queue.c b/src/queue.c index ea0bfb8..395d752 100644 --- a/src/queue.c +++ b/src/queue.c @@ -102,7 +102,7 @@ struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px) struct session *sess; struct server *rsrv; - rsrv = srv->tracked; + rsrv = srv->track; if (!rsrv) rsrv = srv; -- 1.7.2.3