aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2004-10-08 21:15:21 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2004-10-08 21:15:21 +0000
commit2e89951b6f205f847aa4f2e3df81feb3fa8abace (patch)
tree7b46a2c5e1f7848286882520558e9d94e59502b0 /lib/libc
parenta7721a36954ef47975ea575051673509238ea53e (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/syslog.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 2c16d73d46939..5d3a90f135c80 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -243,17 +243,27 @@ vsyslog(pri, fmt, ap)
if (!opened)
openlog(LogTag, LogStat | LOG_NDELAY, 0);
connectlog();
- if (send(LogFile, tbuf, cnt, 0) >= 0)
- 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) /var/run/log is out of socket buffer space
+ * We attempt to reconnect to /var/run/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();
- connectlog();
- if (send(LogFile, tbuf, cnt, 0) >= 0)
- return;
+
+ if (send(LogFile, tbuf, cnt, 0) < 0) {
+ if (errno != ENOBUFS) {
+ disconnectlog();
+ connectlog();
+ }
+ do {
+ usleep(1);
+ if (send(LogFile, tbuf, cnt, 0) >= 0)
+ break;
+ } while (errno == ENOBUFS);
+ }
/*
* Output the message to the console; try not to block