MINOR: log: stop emitting alerts when it's not possible to write on the socket
This is a recurring pain when using certain unix domain sockets or when sending to temporarily unroutable addresses, if the process remains in the foreground, the console is full of error which it's impossible to do anything about. It's even worse when the process is remote, or when run from a serial console which will slow the whole process down. Let's send them only once now to warn about a possible config issue, and not pollute the system nor slow everything down.
This commit is contained in:
parent
fd83f0bfa4
commit
c98aebcdb8
10
src/log.c
10
src/log.c
|
@ -1168,8 +1168,13 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
|||
int proto = logsrv->addr.ss_family == AF_UNIX ? 0 : IPPROTO_UDP;
|
||||
|
||||
if ((*plogfd = socket(logsrv->addr.ss_family, SOCK_DGRAM, proto)) < 0) {
|
||||
static char once;
|
||||
|
||||
if (!once) {
|
||||
once = 1; /* note: no need for atomic ops here */
|
||||
ha_alert("socket for logger #%d failed: %s (errno=%d)\n",
|
||||
nblogger, strerror(errno), errno);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* we don't want to receive anything on this socket */
|
||||
|
@ -1297,11 +1302,16 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
|
|||
sent = sendmsg(*plogfd, &msghdr, MSG_DONTWAIT | MSG_NOSIGNAL);
|
||||
|
||||
if (sent < 0) {
|
||||
static char once;
|
||||
|
||||
if (!once) {
|
||||
once = 1; /* note: no need for atomic ops here */
|
||||
ha_alert("sendmsg logger #%d failed: %s (errno=%d)\n",
|
||||
nblogger, strerror(errno), errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern fd_set hdr_encode_map[];
|
||||
extern fd_set url_encode_map[];
|
||||
|
|
Loading…
Reference in New Issue