summaryrefslogtreecommitdiff
path: root/lib/libc/gen/syslog.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-01-20 20:10:27 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-01-20 20:10:27 +0000
commitd74d9d8fc636aec561b923911e72076143cfc5a0 (patch)
treea7987920498214561b1bd8a1c96f9fabbdf042de /lib/libc/gen/syslog.c
parent8ccb87b8e89170da01c85358cf073b000580d18a (diff)
Don't reconnect to logging socket if send() returns an error and errno
== ENOBUFS, there is no point and it hurts chroot'ed processes. Don't return immediately from syslog_r() when the send(), we may have more work to do. deraadt@ OK
Diffstat (limited to 'lib/libc/gen/syslog.c')
-rw-r--r--lib/libc/gen/syslog.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 7cfed0f076f..090e1f508f2 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.21 2003/01/02 19:39:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: syslog.c,v 1.22 2003/01/20 20:10:26 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -269,8 +269,6 @@ vsyslog_r(pri, data, fmt, ap)
if (!data->opened)
openlog_r(data->log_tag, data->log_stat, 0, data);
connectlog_r(data);
- if (send(data->log_file, tbuf, cnt, 0) >= 0)
- return;
/*
* If the send() failed, there are two likely scenarios:
@@ -280,13 +278,17 @@ vsyslog_r(pri, data, fmt, ap)
* 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);
- do {
- usleep(1);
- if (send(data->log_file, tbuf, cnt, 0) >= 0)
- return;
- } while (errno == ENOBUFS);
+ if (send(data->log_file, tbuf, cnt, 0) < 0) {
+ if (errno != ENOBUFS) {
+ disconnectlog_r(data);
+ connectlog_r(data);
+ }
+ do {
+ usleep(1);
+ if (send(data->log_file, tbuf, cnt, 0) >= 0)
+ break;
+ } while (errno == ENOBUFS);
+ }
/*
* Output the message to the console; try not to block
@@ -306,9 +308,8 @@ vsyslog_r(pri, data, fmt, ap)
(void)close(fd);
}
- if (data != &sdata) {
+ if (data != &sdata)
closelog_r(data);
- }
}
static void