From owner-svn-src-stable-10@freebsd.org Fri Jul 7 11:54:47 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 11C06DA1153; Fri, 7 Jul 2017 11:54:47 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E17D5771E7; Fri, 7 Jul 2017 11:54:46 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v67Bskfu077811; Fri, 7 Jul 2017 11:54:46 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v67Bsk3a077810; Fri, 7 Jul 2017 11:54:46 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201707071154.v67Bsk3a077810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Fri, 7 Jul 2017 11:54:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r320772 - stable/10/usr.sbin/syslogd X-SVN-Group: stable-10 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/10/usr.sbin/syslogd X-SVN-Commit-Revision: 320772 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jul 2017 11:54:47 -0000 Author: eugen (ports committer) Date: Fri Jul 7 11:54:45 2017 New Revision: 320772 URL: https://svnweb.freebsd.org/changeset/base/320772 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/10/usr.sbin/syslogd/syslogd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/10/usr.sbin/syslogd/syslogd.c Fri Jul 7 11:27:12 2017 (r320771) +++ stable/10/usr.sbin/syslogd/syslogd.c Fri Jul 7 11:54:45 2017 (r320772) @@ -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,