Hi, folks.
Syslogd dies on my FreeBSD 4.9 box after reconfiguration that enables remote
logging.
I have looked in mail archives and found PR bin/51253 that describes a
problem.
I am not especial programmer, but that solve the problem:
--- syslogd.c.old Tue May 20 20:13:53 2003
+++ syslogd.c Fri Nov 7 12:10:44 2003
@@ -1072,7 +1072,6 @@
switch (errno) {
case EHOSTUNREACH:
case EHOSTDOWN:
- break;
/* case EBADF: */
/* case EACCES: */
/* case ENOTSOCK: */
Thanks, Nikolay.
NP> Hi, folks.
NP> Syslogd dies on my FreeBSD 4.9 box after reconfiguration that enables
remote logging.
NP> I have looked in mail archives and found PR bin/51253 that describes a
problem.
NP> I am not especial programmer, but that solve the problem:
NP> --- syslogd.c.old Tue May 20 20:13:53 2003
NP> +++ syslogd.c Fri Nov 7 12:10:44 2003
NP> @@ -1072,7 +1072,6 @@
NP> switch (errno) {
NP> case EHOSTUNREACH:
NP> case EHOSTDOWN:
NP> - break;
NP> /* case EBADF: */
NP> /* case EACCES: */
NP> /* case ENOTSOCK: */
NP> Thanks, Nikolay.
Sorry, wrong way. Correct and tested this code:
--- syslogd.c.orig Tue May 20 20:13:53 2003
+++ syslogd.c Mon Nov 10 09:46:54 2003
@@ -1069,24 +1069,9 @@
int e = errno;
logerror("sendto");
errno = e;
- switch (errno) {
- case EHOSTUNREACH:
- case EHOSTDOWN:
- break;
- /* case EBADF: */
- /* case EACCES: */
- /* case ENOTSOCK: */
- /* case EFAULT: */
- /* case EMSGSIZE: */
- /* case EAGAIN: */
- /* case ENOBUFS: */
- /* case ECONNREFUSED: */
- default:
- dprintf("removing entry\n",
e);
- (void)close(f->f_file);
- f->f_type = F_UNUSED;
- break;
- }
+ dprintf("removing entry\n", e);
+ (void)close(f->f_file);
+ f->f_type = F_UNUSED;
}
}
break;
Thanks, Nikolay.
On Tue, Nov 11, 2003 at 10:43:12AM +0200, Nikolay Pavlov wrote:> Sorry, wrong way. Correct and tested this code:I think this patch removes a fix to a different problem, which was that if a syslog server went away for a short amount of time, then syslogd might stop logging to it all together, until syslogd was next HUPed. It would be nice to get a fix that stopped the recursive loggins, but allowed syslogd to recover gracefully from servers that went away for a short time. David.
Hi, David.
DM> I've just committed the following patch to -current, which I think
DM> should fix your problem (and other similar potential problems).
DM> I'll MFC the fix in a couple of weeks, all going according to plan.
DM> David.
DM> Index: syslogd.c
DM> ==================================================================DM>
RCS file: /cvs/FreeBSD-CVS/src/usr.sbin/syslogd/syslogd.c,v
DM> retrieving revision 1.116
DM> diff -u -r1.116 syslogd.c
DM> --- syslogd.c 17 May 2003 20:07:54 -0000 1.116
DM> +++ syslogd.c 16 Nov 2003 20:45:40 -0000
DM> @@ -1338,7 +1338,12 @@
DM> logerror(const char *type)
DM> {
DM> char buf[512];
DM> + static int recursed = 0;
DM> + /* If there's an error while trying to log an error, give up.
*/
DM> + if (recursed)
DM> + return;
DM> + recursed++;
DM> if (errno)
DM> (void)snprintf(buf,
DM> sizeof buf, "syslogd: %s: %s", type,
strerror(errno));
DM> @@ -1347,6 +1352,7 @@
DM> errno = 0;
DM> dprintf("%s\n", buf);
DM> logmsg(LOG_SYSLOG|LOG_ERR, buf, LocalHostName, ADDDATE);
DM> + recursed--;
DM> }
DM> static void
Your patch works excellent for my 4.9 box, thanks that found time for
this.
--
Thanks, Nikolay.