diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-06-05 17:13:50 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-06-05 17:13:50 +0000 |
commit | 28e7ba32015fef1cbed131a2f1118457c42f8d75 (patch) | |
tree | 623489884cb18e3e24a02a87c6ac528bf53ad232 /lib/libc/gen/syslog.c | |
parent | 09d05ec4924d16cf49835603ba84f65588754779 (diff) |
If send() returns ENOBUFS, sleep for one microsecond and retry.
deraadt@ OK
Diffstat (limited to 'lib/libc/gen/syslog.c')
-rw-r--r-- | lib/libc/gen/syslog.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 892a0f3a006..da64fc913c2 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: syslog.c,v 1.17 2002/05/26 09:29:02 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: syslog.c,v 1.18 2002/06/05 17:13:49 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -268,13 +268,20 @@ vsyslog_r(pri, data, fmt, ap) return; /* - * If the send() failed, the odds are syslogd was restarted. - * Make one (only) attempt to reconnect to /dev/log. + * If the send() failed, there are two likely scenarios: + * 1) syslogd was restarted + * 2) /dev/log is out of socket buffer space + * We attempt to reconnect to /dev/log to take care of + * case #1 and keep send()ing data to cover case #2 + * to give syslogd a chance to empty its socket buffer. */ disconnectlog_r(data); connectlog_r(data); - if (send(data->log_file, tbuf, cnt, 0) >= 0) - return; + do { + usleep(1); + if (send(data->log_file, tbuf, cnt, 0) >= 0) + return; + } while (errno == ENOBUFS); /* * Output the message to the console; try not to block |