From 3e976b12e04be1fad11f6a992c73bae216c111a4 Mon Sep 17 00:00:00 2001 From: csjp Date: Thu, 30 Mar 2006 21:04:52 +0000 Subject: Currently, if writing out a log entry fails, we unlink that log entry from our internal list of logfiles. So if writev(2) fails for potentially transient errors like ENOSPC, syslogd requires a restart, even if the filesystem has purged. This change allows syslogd to ignore ENOSPC space errors, so that when the filesystem is cleaned up, syslogd will automatically start logging again without requiring the reset. This makes syslogd(8) a bit more reliable. MFC after: 1 week --- usr.sbin/syslogd/syslogd.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'usr.sbin/syslogd') diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index a41b22c..23e30f8 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1227,11 +1227,18 @@ fprintlog(struct filed *f, int flags, const char *msg) v->iov_base = lf; v->iov_len = 1; if (writev(f->f_file, iov, 7) < 0) { - int e = errno; - (void)close(f->f_file); - f->f_type = F_UNUSED; - errno = e; - logerror(f->f_un.f_fname); + /* + * If writev(2) fails for potentially transient errors + * like the * filesystem being full, ignore it. + * Otherwise remove * this logfile from the list. + */ + if (errno != ENOSPC) { + int e = errno; + (void)close(f->f_file); + f->f_type = F_UNUSED; + errno = e; + logerror(f->f_un.f_fname); + } } else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC)) { f->f_flags |= FFLAG_NEEDSYNC; needdofsync = 1; -- cgit v1.1