syslogd/sysklogd-1.4.1-reopen.patch
Marcus Meissner 53bbc01f78 Accepting request 24994 from home:elvigia:branches:Base:System
Copy from home:elvigia:branches:Base:System/syslogd via accept of submit request 24994 revision 2.
Request was accepted with message:
ok

OBS-URL: https://build.opensuse.org/request/show/24994
OBS-URL: https://build.opensuse.org/package/show/Base:System/syslogd?expand=0&rev=10
2009-11-25 15:23:34 +00:00

43 lines
1.3 KiB
Diff

#
# Description: reconnects to log socket if a write fails with
# ECONNREFUSED or ENOTCONN -- similar to reopen
# in syslog routines provided by glibc.
# Happens if the log socket (provided by syslog
# daemon) has been reopened. Can be triggered by
# "rcsyslog reload" while syslog-ng is used.
# See also Bugzilla Bug #27971.
#
# Author: mt@suse.de
#
Index: syslog.c
===================================================================
--- syslog.c.orig 2009-11-24 18:12:52.145473000 +0100
+++ syslog.c 2009-11-24 18:12:54.173290000 +0100
@@ -97,7 +97,7 @@ vsyslog(pri, fmt, ap)
register int cnt;
register char *p;
time_t now;
- int fd, saved_errno;
+ int fd, saved_errno, rc;
char tbuf[2048], fmt_cpy[1024], *stdp = (char *) 0;
saved_errno = errno;
@@ -167,7 +167,16 @@ vsyslog(pri, fmt, ap)
}
/* output the message to the local logger */
- if (write(LogFile, tbuf, cnt + 1) >= 0 || !(LogStat&LOG_CONS))
+ rc = write(LogFile, tbuf, cnt + 1);
+ if(rc == -1 && connected && (ECONNREFUSED == errno ||
+ ENOTCONN == errno)) {
+ /* try to reopen and write again */
+ closelog();
+ openlog(LogTag, LogStat | LOG_NDELAY, LogFacility);
+ if(connected)
+ rc = write(LogFile, tbuf, cnt + 1);
+ }
+ if(rc >= 0 || !(LogStat&LOG_CONS))
return;
/*