BUG/MEDIUM: servers: Add srv_addr default placeholder to the state file

When creating a state file using "show servers state" an empty field is
created in the srv_addr column if the server is from the socket family
AF_UNIX.  This leads to a warning on start up when using
"load-server-state-from-file". This patch defaults srv_addr to "-" if
the socket family is not covered.

This patch should be backported to 1.8.
This commit is contained in:
Daniel Corbett 2018-05-19 19:43:24 -04:00 committed by Willy Tarreau
parent 0cd82e883e
commit 9215ffa6b2
2 changed files with 5 additions and 1 deletions

View File

@ -1450,6 +1450,9 @@ static int dump_servers_state(struct stream_interface *si, struct chunk *buf)
inet_ntop(srv->addr.ss_family, &((struct sockaddr_in6 *)&srv->addr)->sin6_addr,
srv_addr, INET6_ADDRSTRLEN + 1);
break;
default:
memcpy(srv_addr, "-\0", 2);
break;
}
srv_time_since_last_change = now.tv_sec - srv->last_change;
bk_f_forced_id = px->options & PR_O_FORCED_ID ? 1 : 0;

View File

@ -2936,7 +2936,8 @@ static void srv_update_state(struct server *srv, int version, char **params)
server_recalc_eweight(srv);
/* load server IP address */
srv->lastaddr = strdup(params[0]);
if (strcmp(params[0], "-"))
srv->lastaddr = strdup(params[0]);
if (fqdn && srv->hostname) {
if (!strcmp(srv->hostname, fqdn)) {