summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authoreugen <eugen@FreeBSD.org>2017-07-07 11:54:45 +0000
committereugen <eugen@FreeBSD.org>2017-07-07 11:54:45 +0000
commit002f0e2689c0297acef6d9f709c7cc774b30fa24 (patch)
tree8901e9108a2029445bd7cf3e7bd8dfcd29ac58af /usr.sbin
parentbfafd405cda18624b5699ffe33e4ca0d45a8a2db (diff)
downloadFreeBSD-src-002f0e2689c0297acef6d9f709c7cc774b30fa24.zip
FreeBSD-src-002f0e2689c0297acef6d9f709c7cc774b30fa24.tar.gz
MFC r310888:
Retry to open an F_PIPE process when it dies unexpectedly. PR: 215335 Reviewed by: ae Approved by: az (mentor)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 3d5429f..d09ec02 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -349,9 +349,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
@@ -1311,18 +1321,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);
}
@@ -1427,7 +1435,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;
@@ -1529,10 +1536,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) {
@@ -1599,12 +1604,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;
@@ -2582,6 +2584,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,
OpenPOWER on IntegriCloud