Date: Thu, 21 Dec 1995 04:44:24 -0600 From: rkw@dataplex.net (Richard Wackerbarth) To: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?=(aka Andrey A. Chernov, Black Mage) <ache@astral.msk.su> Cc: hackers@freebsd.org Subject: Re: weekly/monthly logs rotating idea (commit candidate) Message-ID: <v02140a01acfee9941c2b@[199.183.109.242]>
next in thread | raw e-mail | index | archive | help
OBJECTION!!!!!!!! We do not have locking on the logs. As a result, there is a race condition in your code. The daemon wants to write a multi-write message to the log. An incomplete message ends up in the log. Or worse yet, a message gets lost entirely between the copy and the truncate. The present code is correct with the addition of the "restart" event (SIG-HUP?) to tell the daemon to reopen its log file. >Current logs rotating code > ... > if [ -f $i.1 ]; then mv -f $i.1 $i.2; fi > if [ -f $i.0 ]; then mv -f $i.0 $i.1; fi > if [ -f $i ]; then mv -f $i $i.0; fi > >$i >isn't good for daemons, because thet keep log descriptor open. >It means that daemon_log moved to daemon_log.0 and diagnostics >still writted to daemon_log.0! New daemon_log leaves zero-sized >until reboot. > >What I suggest: > > if [ -f $i.0 ]; then mv -f $i.0 $i.1; fi > if [ -f $i ]; then cp -fp $i $i.0; fi > >$i > >It means that you copy log preserving file times and then >zero the same descriptor. > >If I not see objections with explanations, I plan to commit it. ---- Richard Wackerbarth rkw@dataplex.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?v02140a01acfee9941c2b>