Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2023 15:52:36 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: bbde787c6668 - main - syslogd: Merge loops
Message-ID:  <202309281552.38SFqaxk022072@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=bbde787c6668803e2c4e999ef699d545b26160a6

commit bbde787c6668803e2c4e999ef699d545b26160a6
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2023-09-01 02:50:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-09-28 15:51:53 +0000

    syslogd: Merge loops
    
    Merge the two loops that traverse the global filed queue. Both loops'
    actions are not dependent on the other, so combining them is safe.
    
    Reviewed by:    markj
    MFC after:      3 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D41370
---
 usr.sbin/syslogd/syslogd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index c20928d48495..a37f3a9482bf 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -2575,7 +2575,10 @@ init(bool reload)
 	 *  Close all open log files.
 	 */
 	Initialized = false;
-	STAILQ_FOREACH(f, &fhead, next) {
+	while (!STAILQ_EMPTY(&fhead)) {
+		f = STAILQ_FIRST(&fhead);
+		STAILQ_REMOVE_HEAD(&fhead, next);
+
 		/* flush any pending output */
 		if (f->f_prevcount)
 			fprintlog_successive(f, 0);
@@ -2593,10 +2596,7 @@ init(bool reload)
 		default:
 			break;
 		}
-	}
-	while(!STAILQ_EMPTY(&fhead)) {
-		f = STAILQ_FIRST(&fhead);
-		STAILQ_REMOVE_HEAD(&fhead, next);
+
 		free(f->f_program);
 		free(f->f_host);
 		if (f->f_prop_filter) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309281552.38SFqaxk022072>