mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-01 22:48:25 +00:00
BUG/MINOR: extcheck: add missing checks on extchk_setenv()
Issue #910 reports that we fail to check a few extchk_setenv() in the child process. These are mostly harmless, but instead of counting on the external check script to fail the dirty way, better fail cleanly when detecting the failure. This could probably be backported to all stable branches.
This commit is contained in:
parent
5472aa50f1
commit
b3250a268b
@ -427,20 +427,21 @@ static int connect_proc_chk(struct task *t)
|
||||
environ = check->envp;
|
||||
|
||||
/* Update some environment variables and command args: curconn, server addr and server port */
|
||||
extchk_setenv(check, EXTCHK_HAPROXY_SERVER_CURCONN, ultoa_r(s->cur_sess, buf, sizeof(buf)));
|
||||
EXTCHK_SETENV(check, EXTCHK_HAPROXY_SERVER_CURCONN, ultoa_r(s->cur_sess, buf, sizeof(buf)), fail);
|
||||
|
||||
addr_to_str(&s->addr, check->argv[3], EXTCHK_SIZE_ADDR);
|
||||
extchk_setenv(check, EXTCHK_HAPROXY_SERVER_ADDR, check->argv[3]);
|
||||
EXTCHK_SETENV(check, EXTCHK_HAPROXY_SERVER_ADDR, check->argv[3], fail);
|
||||
|
||||
*check->argv[4] = 0;
|
||||
if (s->addr.ss_family == AF_INET || s->addr.ss_family == AF_INET6)
|
||||
snprintf(check->argv[4], EXTCHK_SIZE_UINT, "%u", s->svc_port);
|
||||
extchk_setenv(check, EXTCHK_HAPROXY_SERVER_PORT, check->argv[4]);
|
||||
EXTCHK_SETENV(check, EXTCHK_HAPROXY_SERVER_PORT, check->argv[4], fail);
|
||||
|
||||
haproxy_unblock_signals();
|
||||
execvp(px->check_command, check->argv);
|
||||
ha_alert("Failed to exec process for external health check: %s. Aborting.\n",
|
||||
strerror(errno));
|
||||
fail:
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user