[Dnsmasq-discuss] log rotation again...

Simon Kelley simon at thekelleys.org.uk
Tue May 1 20:23:16 BST 2007

Carlos Carvalho wrote:
> It seems this has been sent this only to me but since Simon asks
> everybody (at the end) I'm answering to the list.

Ah, sorry. WrongButtonError.

> Exactly, that's what I had in mind. The savelog script in Debian can
> also do it.

Another new thing I learned today. I don't like savelog's compression 
scheme though. Ignoring the older files, is seems to to

mv log.0 log.1
compress log.1
touch log.0

and then the signal can be sent. Since the old file (renamed to log.1) 
can still be written 'till the signal is sent, and some time afterwards,
then the compressedfile might be written to and corrupted. I think the 
scheme where log.0 and log.1 are uncompressed and only log.2, log3 etc 
are compressed is much safer.
>  >Adding the signal is slightly non-trivial (there's a whole set of
>  >processes which might have the log file open) but it should be possible.
> I trust you :-)

I'll get some code out this week sometime, unless I get too busy.
>  >Does anybody have an opinion on the best signal to use , given that
>  >SIGHUP is already taken?
> I'd go with USR2 as you suggested. HUP can also do it in addition to
> what it already does, like some other daemons do.

SIGUSR2 it is.
> One thing that is different in dnsmasq compared to many other daemons
> is that HUP does not re-read the main config, so it's not a full
> reload. I guess that's because dnsmasq has a lot of state to preserve
> (other processes, cache, leases). Is this correct?

The overriding reason is that some start-up actions need root 
permissions, which get thrown away after start-up. Imagine that you 
change dnsmasq.conf to enable DHCP and SIGHUP. Dnsmasq re-reads the file 
and needs to open port 68 to do DHCP, but that needs root permissions.

The state isn't a problem: the only thing that needs to be kept is the 
lease database, and that's safely in a file. Dnsmasq is designed to be 
re-startable at any point without loosing data. It would be possible to 
make a root process which forks the real process, and can kill it and 
re-fork a new one with new configuration, but that's just equivalent to 
killing and restarting the daemon anyway, and costs another process in 
memory at all times.



> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

More information about the Dnsmasq-discuss mailing list