Menu

#34 @records preserved across changes to config file

open
nobody
None
5
2006-08-18
2006-08-18
No

In swatch, starting at line 190:

{
my @records;
sub read_config {

So @records is a "closure" of sorts. This means that on
receiving a SIG_HUP, the config file will be reread but
@records is preserved across calls to read_config()
because it lives outside the sub read_config
declaration. This means that the configuration (i.e.
@records) is being appended to instead of being
recreated during read_config()). You can reproduce this
by _changing_ any action in a watchfor statement in a
simple swatch.conf, sig huping swatch and then
examining the generated .swatch_script.$$. The
generated script just keeps growing and the old
watchfor constructs are still in it. I'm guessing that
someone was trying to support recursive calls to
read_config() via the undocumented include statement
and maybe got it wrong? Here is a patch that fixes the
problem and recursive calls to read_config() via the
undocumented "include" statement. Tested only mildly:

190a191
> my @records;
201,202d201
< my @records;
<
246c245
< push(@records, read_config($val));
---
> @records = read_config($val);

Also, the generated .swatch_script.$$ uses strict so
perlcode vars declaration must use "my". Didn't see
that in the man page.

This is swatch version 3.2.1
Built on July 21, 2006
Built by E. Todd Atkins <Todd.Atkins@StanfordAlumni.ORG>

Linux myhost 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28
EST 2006 x86_64 x86_64 x86_64 GNU/Linux

This is perl, v5.8.5 built for x86_64-linux-thread-multi

Invoked from syslog-ng as:
/usr/bin/swatch
--config-file=/usr/local/etc/syslog-ng/swatch.conf
--read-pipe=\"cat /dev/fd/0\"

Discussion


Log in to post a comment.

Monday.com Logo