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.
This commit is contained in:
Willy Tarreau 2011-10-28 15:35:33 +02:00
parent d66bf96d5b
commit 4426770013
5 changed files with 18 additions and 18 deletions

View File

@ -110,7 +110,7 @@ struct server {
char *iface_name; /* bind interface name or NULL */ char *iface_name; /* bind interface name or NULL */
struct port_range *sport_range; /* optional per-server TCP source ports */ 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 */ char *trackit; /* temporary variable to make assignment deferrable */
struct sockaddr_storage check_addr; /* the address to check, if different from <addr> */ struct sockaddr_storage check_addr; /* the address to check, if different from <addr> */
short check_port; /* the port to use for the health checks */ short check_port; /* the port to use for the health checks */

View File

@ -6235,7 +6235,7 @@ out_uri_auth_compat:
goto next_srv; goto next_srv;
} }
newsrv->tracked = srv; newsrv->track = srv;
newsrv->tracknext = srv->tracknext; newsrv->tracknext = srv->tracknext;
srv->tracknext = newsrv; srv->tracknext = newsrv;

View File

@ -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) { 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", 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) { if (options & SSP_O_HCHK) {
chunk_printf(msg, ", reason: %s", get_check_status_description(s->check_status)); 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; 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 srv_was_paused = s->state & SRV_GOINGDOWN;
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act; 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); s->proxy->id, s->id);
server_status_printf(&msg, s, 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); xferred);
} }
Warning("%s.\n", trash); Warning("%s.\n", trash);
@ -449,7 +449,7 @@ void set_server_up(struct server *s) {
s->health = s->rise; 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->srv_bck == 0 && s->proxy->srv_act == 0) {
if (s->proxy->last_change < now.tv_sec) // ignore negative times if (s->proxy->last_change < now.tv_sec) // ignore negative times
s->proxy->down_time += now.tv_sec - s->proxy->last_change; 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); s->proxy->id, s->id);
server_status_printf(&msg, s, 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); xferred);
} }
@ -536,7 +536,7 @@ static void set_server_disabled(struct server *s) {
s->proxy->id, s->id); s->proxy->id, s->id);
server_status_printf(&msg, s, 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); xferred);
Warning("%s.\n", trash); Warning("%s.\n", trash);
@ -572,7 +572,7 @@ static void set_server_enabled(struct server *s) {
s->proxy->id, s->id); s->proxy->id, s->id);
server_status_printf(&msg, s, 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); xferred);
Warning("%s.\n", trash); Warning("%s.\n", trash);

View File

@ -1159,11 +1159,11 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
if (sv->state & SRV_MAINTAIN) { if (sv->state & SRV_MAINTAIN) {
/* The server is really in maintenance, we can change the server state */ /* 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, /* If this server tracks the status of another one,
* we must restore the good status. * we must restore the good status.
*/ */
if (sv->tracked->state & SRV_RUNNING) { if (sv->track->state & SRV_RUNNING) {
set_server_up(sv); set_server_up(sv);
sv->health = sv->rise; /* up, but will fall down at first failure */ sv->health = sv->rise; /* up, but will fall down at first failure */
} else { } 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 session *s = si->applet.private;
struct buffer *rep = si->ib; 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 listener *l;
struct chunk msg; struct chunk msg;
@ -2541,8 +2541,8 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
continue; continue;
} }
if (sv->tracked) if (sv->track)
svs = sv->tracked; svs = sv->track;
else else
svs = sv; 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); chunk_printf(&msg, ",%lld,", sv->counters.cum_lbconn);
/* tracked */ /* tracked */
if (sv->tracked) if (sv->track)
chunk_printf(&msg, "%s/%s,", chunk_printf(&msg, "%s/%s,",
sv->tracked->proxy->id, sv->tracked->id); sv->track->proxy->id, sv->track->id);
else else
chunk_printf(&msg, ","); chunk_printf(&msg, ",");

View File

@ -102,7 +102,7 @@ struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px)
struct session *sess; struct session *sess;
struct server *rsrv; struct server *rsrv;
rsrv = srv->tracked; rsrv = srv->track;
if (!rsrv) if (!rsrv)
rsrv = srv; rsrv = srv;