From dean-debian@arctic.org Mon Jul 29 21:33:31 2002
Date: Mon, 29 Jul 2002 21:33:21 -0700 (PDT)
From: dean gaudet <dean-debian@arctic.org>
To: submit@bugs.debian.org
Subject: SIGHUP handling race condition
X-comment: visit http://arctic.org/~dean/legal for information regarding
    copyright and disclaimer.

Package: sysklogd
Version: 1.4.1-10

the patch below fixes a race condition in the SIGHUP handling in syslogd.
i noticed it because i was using a legacy logrotation tool which was doing
the following:

	mv loga loga.1
	kill -HUP `cat /var/run/syslogd.pid`
	mv logb logb.1
	kill -HUP `cat /var/run/syslogd.pid`
	mv logc logc.1
	kill -HUP `cat /var/run/syslogd.pid`

i've got a fast enough dual proc system that these mv and kills were
occuring faster than the init() code within syslogd.  periodically syslogd
would not re-open logc, and would continue logging to logc.1 for the
next day.  this is because the HUP was arriving during the init() code
and it was lost.

the patch below should fix the bug... mind you i haven't tested it
thoroughly.  (i changed my legacy rotation script to use a single
kill -HUP as well 'cause i'm tired of losing logs :)

-dean

--- sysklogd-1.4.1/syslogd.c.race	Sun Mar 11 11:40:10 2001
+++ sysklogd-1.4.1/syslogd.c	Mon Jul 29 21:24:27 2002
@@ -1075,8 +1075,8 @@
 		if ( restart )
 		{
 			dprintf("\nReceived SIGHUP, reloading syslogd.\n");
-			init();
 			restart = 0;
+			init();
 			continue;
 		}
 		if (nfds == 0) {

