mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
[MINOR] startup: print the proxy socket which caused an error
Add the address and port to the error message of the proxy socket that caused the error. This can be helpful when several listening addresses are used in a proxy. Edit: since we now also support unix sockets (which already report their path), better move the address reporting to proto_tcp.c by analogy. -Willy
This commit is contained in:
parent
17f449b214
commit
43ba1b331c
@ -559,8 +559,22 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
|||||||
fd_insert(fd);
|
fd_insert(fd);
|
||||||
|
|
||||||
tcp_return:
|
tcp_return:
|
||||||
if (msg && errlen)
|
if (msg && errlen) {
|
||||||
strlcpy2(errmsg, msg, errlen);
|
char pn[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
|
if (listener->addr.ss_family == AF_INET) {
|
||||||
|
inet_ntop(AF_INET,
|
||||||
|
(const void *)&((struct sockaddr_in *)&listener->addr)->sin_addr,
|
||||||
|
pn, sizeof(pn));
|
||||||
|
snprintf(errmsg, errlen, "%s [%s:%d]", msg, pn, ntohs(((struct sockaddr_in *)&listener->addr)->sin_port));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inet_ntop(AF_INET6,
|
||||||
|
(const void *)&((struct sockaddr_in6 *)(&listener->addr))->sin6_addr,
|
||||||
|
pn, sizeof(pn));
|
||||||
|
snprintf(errmsg, errlen, "%s [%s:%d]", msg, pn, ntohs(((struct sockaddr_in6 *)&listener->addr)->sin6_port));
|
||||||
|
}
|
||||||
|
}
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
tcp_close_return:
|
tcp_close_return:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user