svn commit: r320776 - stable/11/usr.sbin/syslogd
Eugene Grosbein
eugen at FreeBSD.org
Fri Jul 7 13:44:20 UTC 2017
Author: eugen (ports committer)
Date: Fri Jul 7 13:44:18 2017
New Revision: 320776
URL: https://svnweb.freebsd.org/changeset/base/320776
Log:
MFC r310888:
Retry to open an F_PIPE process when it dies unexpectedly.
PR: 215335
Reviewed by: ae
Approved by: az (mentor)
Modified:
stable/11/usr.sbin/syslogd/syslogd.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/usr.sbin/syslogd/syslogd.c
==============================================================================
--- stable/11/usr.sbin/syslogd/syslogd.c Fri Jul 7 13:44:14 2017 (r320775)
+++ stable/11/usr.sbin/syslogd/syslogd.c Fri Jul 7 13:44:18 2017 (r320776)
@@ -362,9 +362,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->f_un.f_pipe.f_pid = 0;
+ break;
+ }
(void)close(f->f_file);
f->f_file = -1;
- f->f_type = F_UNUSED;
}
int
@@ -1346,18 +1356,16 @@ fprintlog(struct filed *f, int flags, const char *msg)
if (f->f_un.f_pipe.f_pid == 0) {
if ((f->f_file = p_open(f->f_un.f_pipe.f_pname,
&f->f_un.f_pipe.f_pid)) < 0) {
- f->f_type = F_UNUSED;
logerror(f->f_un.f_pipe.f_pname);
break;
}
}
if (writev(f->f_file, iov, IOV_SIZE) < 0) {
int e = errno;
+
close_filed(f);
- if (f->f_un.f_pipe.f_pid > 0)
- deadq_enter(f->f_un.f_pipe.f_pid,
- f->f_un.f_pipe.f_pname);
- f->f_un.f_pipe.f_pid = 0;
+ deadq_enter(f->f_un.f_pipe.f_pid,
+ f->f_un.f_pipe.f_pname);
errno = e;
logerror(f->f_un.f_pipe.f_pname);
}
@@ -1485,7 +1493,6 @@ reapchild(int signo __unused)
if (f->f_type == F_PIPE &&
f->f_un.f_pipe.f_pid == pid) {
close_filed(f);
- f->f_un.f_pipe.f_pid = 0;
log_deadchild(pid, status,
f->f_un.f_pipe.f_pname);
break;
@@ -1587,10 +1594,8 @@ die(int signo)
/* flush any pending output */
if (f->f_prevcount)
fprintlog(f, 0, (char *)NULL);
- if (f->f_type == F_PIPE && f->f_un.f_pipe.f_pid > 0) {
+ if (f->f_type == F_PIPE && f->f_un.f_pipe.f_pid > 0)
close_filed(f);
- f->f_un.f_pipe.f_pid = 0;
- }
}
Initialized = was_initialized;
if (signo) {
@@ -1823,12 +1828,9 @@ init(int signo)
close_filed(f);
break;
case F_PIPE:
- if (f->f_un.f_pipe.f_pid > 0) {
- close_filed(f);
- deadq_enter(f->f_un.f_pipe.f_pid,
- f->f_un.f_pipe.f_pname);
- }
- f->f_un.f_pipe.f_pid = 0;
+ close_filed(f);
+ deadq_enter(f->f_un.f_pipe.f_pid,
+ f->f_un.f_pipe.f_pname);
break;
}
next = f->f_next;
@@ -2730,6 +2732,8 @@ deadq_enter(pid_t pid, const char *name)
dq_t p;
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,
More information about the svn-src-all
mailing list