diff options
author | 2002-06-05 17:13:49 +0000 | |
---|---|---|
committer | 2002-06-05 17:13:49 +0000 | |
commit | 7590331ddd0bf3f31c5e24eb44e5f10beab46c84 (patch) | |
tree | 473f2536adf9013fa2fb7f3a4a5ca4d5c83e177e /lib/libc/gen/syslog.c | |
parent | Double socket receive buffer size; deraadt@ OK (diff) | |
download | wireguard-openbsd-7590331ddd0bf3f31c5e24eb44e5f10beab46c84.tar.xz wireguard-openbsd-7590331ddd0bf3f31c5e24eb44e5f10beab46c84.zip |
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 |