From 795245bfaaadd81d9ee7e6f6516bb51315222b12 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Wed, 27 Aug 2003 15:56:01 +0000 Subject: [PATCH] Improved patch by Michael Pomraning to reconnect klogd to the logger after it went away, so messages won't get lost if the logger is already around by trying to reopen the socket in time. --- CHANGES | 11 +++++++++++ syslog.c | 15 +++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 8fdf8fd..e566eb7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Version 1.4.2 + + . klogd will reconnect to the logger (mostly syslogd) after it went + away. + Version 1.4.1 . klogd will set the console log level only if `-c' is given on the @@ -31,3 +36,9 @@ Version 1.4 - Remove Unix Domain Sockets and switch to Datagram Unix Sockets . Several bugfixes and improvements, please refer to the .c files + +Local variables: +mode: indented-text +mode: iso-accents +fill-column: 72 +End: diff --git a/syslog.c b/syslog.c index 366635b..bdb3ff2 100644 --- a/syslog.c +++ b/syslog.c @@ -47,6 +47,9 @@ static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90"; * Sun Mar 11 20:23:44 CET 2001: Martin Schulze * Use SOCK_DGRAM for loggin, renables it to work. * + * Wed Aug 27 17:48:16 CEST 2003: Martin Schulze + * Improved patch by Michael Pomraning to + * reconnect klogd to the logger after it went away. */ #include @@ -97,7 +100,8 @@ vsyslog(pri, fmt, ap) register int cnt; register char *p; time_t now; - int fd, r, saved_errno; + int fd, saved_errno; + int result; char tbuf[2048], fmt_cpy[1024], *stdp = (char *) 0; saved_errno = errno; @@ -167,13 +171,16 @@ vsyslog(pri, fmt, ap) } /* output the message to the local logger */ - r = write(LogFile, tbuf, cnt + 1); + result = write(LogFile, tbuf, cnt + 1); - if (r == -1 && (errno == ECONNRESET || errno == ENOTCONN)) { + if (result == -1 + && (errno == ECONNRESET || errno == ENOTCONN || errno == ECONNREFUSED)) { closelog(); + openlog(LogTag, LogStat | LOG_NDELAY, LogFacility); + result = write(LogFile, tbuf, cnt + 1); } - if (r >= 0 || !(LogStat&LOG_CONS)) + if (result >= 0 || !(LogStat&LOG_CONS)) return; /*