mirror of git://git.musl-libc.org/musl
check for connect failure in syslog log opening
based on patch by Dima Krasner, with minor improvements for code size. connect can fail if there is no listening syslogd, in which case a useless socket was kept open, preventing subsequent syslog call from attempting to connect again.
This commit is contained in:
parent
11ac2a6e81
commit
c574321d75
|
@ -46,8 +46,12 @@ void closelog(void)
|
||||||
|
|
||||||
static void __openlog()
|
static void __openlog()
|
||||||
{
|
{
|
||||||
log_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
int fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||||
if (log_fd >= 0) connect(log_fd, (void *)&log_addr, sizeof log_addr);
|
if (fd < 0) return;
|
||||||
|
if (connect(fd, (void *)&log_addr, sizeof log_addr) < 0)
|
||||||
|
close(fd);
|
||||||
|
else
|
||||||
|
log_fd = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openlog(const char *ident, int opt, int facility)
|
void openlog(const char *ident, int opt, int facility)
|
||||||
|
|
Loading…
Reference in New Issue