The healthcheck keyword could be parsed on default-server lines but not
copied during server initialization, making it ineffective. But there is
also a true issue by setting it on a default-server. The pseudo server used
to parse the default-server line is not initialized via the new_server()
function, as regular servers. So there is no tcpcheck information inherited
from the proxy. We must take care of that when the "healthcheck" keyword is
parsed to avoid crashes.
This patch must be backported to 3.4.
srv->check.alpn_len = src->check.alpn_len;
}
}
+ if (src->check.tcpcheck && src->check.tcpcheck->healthcheck) {
+ struct tcpcheck *tcpcheck = NULL;
+
+ tcpcheck = calloc(1, sizeof(*tcpcheck));
+ if (tcpcheck) {
+ LIST_INIT(&tcpcheck->preset_vars);
+ tcpcheck->healthcheck = strdup(src->check.tcpcheck->healthcheck);
+ if (tcpcheck->healthcheck == NULL)
+ ha_free(&tcpcheck);
+ }
+ if (tcpcheck)
+ srv->check.tcpcheck = tcpcheck;
+ }
if (!(srv->flags & SRV_F_RHTTP))
srv->check.reuse_pool = src->check.reuse_pool;
goto out;
}
- if (srv->check.tcpcheck->healthcheck) {
+ if (srv->check.tcpcheck && srv->check.tcpcheck->healthcheck) {
/* a healthcheck section was already defined. Replace it */
ha_free(&srv->check.tcpcheck->healthcheck);
}