]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: servers: Add srv_addr default placeholder to the state file
authorDaniel Corbett <dcorbett@haproxy.com>
Sat, 19 May 2018 23:43:24 +0000 (19:43 -0400)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 May 2018 20:06:08 +0000 (22:06 +0200)
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.

src/proxy.c
src/server.c

index 31253f14dcd2d497d76d2ae286d217bf5b1158fe..6f71b4b4c5a0efc2675bd43ffc79c361c34e7ebf 100644 (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;
index ebac357fba8ccd40335f5254964d60c98470c45a..277d1405e78393d3004d8a8ebfe11f0f81e9f7b0 100644 (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)) {