Date: Sat, 31 Dec 2016 03:07:48 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310888 - head/usr.sbin/syslogd Message-ID: <201612310307.uBV37miu046767@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hrs Date: Sat Dec 31 03:07:48 2016 New Revision: 310888 URL: https://svnweb.freebsd.org/changeset/base/310888 Log: Retry to open an F_PIPE process when it dies unexpectedly. Reported by: Eugene Grosbein PR: 215335 Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Dec 31 02:23:15 2016 (r310887) +++ head/usr.sbin/syslogd/syslogd.c Sat Dec 31 03:07:48 2016 (r310888) @@ -368,9 +368,19 @@ close_filed(struct filed *f) if (f == NULL || f->f_file == -1) return; + switch (f->f_type) { + case F_FILE: + case F_TTY: + case F_CONSOLE: + case F_FORW: + f->f_type = F_UNUSED; + break; + case F_PIPE: + f->fu_pipe_pid = 0; + break; + } (void)close(f->f_file); f->f_file = -1; - f->f_type = F_UNUSED; } static int @@ -1378,18 +1388,15 @@ fprintlog(struct filed *f, int flags, co if (f->fu_pipe_pid == 0) { if ((f->f_file = p_open(f->fu_pipe_pname, &f->fu_pipe_pid)) < 0) { - f->f_type = F_UNUSED; logerror(f->fu_pipe_pname); break; } } if (writev(f->f_file, iov, nitems(iov)) < 0) { int e = errno; + + deadq_enter(f->fu_pipe_pid, f->fu_pipe_pname); close_filed(f); - if (f->fu_pipe_pid > 0) - deadq_enter(f->fu_pipe_pid, - f->fu_pipe_pname); - f->fu_pipe_pid = 0; errno = e; logerror(f->fu_pipe_pname); } @@ -1520,7 +1527,6 @@ reapchild(int signo __unused) if (f->f_type == F_PIPE && f->fu_pipe_pid == pid) { close_filed(f); - f->fu_pipe_pid = 0; log_deadchild(pid, status, f->fu_pipe_pname); break; } @@ -1619,10 +1625,8 @@ die(int signo) /* flush any pending output */ if (f->f_prevcount) fprintlog(f, 0, (char *)NULL); - if (f->f_type == F_PIPE && f->fu_pipe_pid > 0) { + if (f->f_type == F_PIPE && f->fu_pipe_pid > 0) close_filed(f); - f->fu_pipe_pid = 0; - } } Initialized = was_initialized; if (signo) { @@ -1851,12 +1855,8 @@ init(int signo) close_filed(f); break; case F_PIPE: - if (f->fu_pipe_pid > 0) { - close_filed(f); - deadq_enter(f->fu_pipe_pid, - f->fu_pipe_pname); - } - f->fu_pipe_pid = 0; + deadq_enter(f->fu_pipe_pid, f->fu_pipe_pname); + close_filed(f); break; } } @@ -2753,6 +2753,8 @@ deadq_enter(pid_t pid, const char *name) struct deadq_entry *dq; int status; + if (pid == 0) + return; /* * Be paranoid, if we can't signal the process, don't enter it * into the dead queue (perhaps it's already dead). If possible,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612310307.uBV37miu046767>