diff options
author | Tobi Oetiker <tobi@oetiker.ch> | 2008-08-13 22:13:37 +0200 |
---|---|---|
committer | Tobi Oetiker <tobi@oetiker.ch> | 2008-08-13 22:13:37 +0200 |
commit | f160d040a25f4bc6c33787326b581a49c2e38cce (patch) | |
tree | 5f28de8a6434183105ba2a7eec65f14e0d59466e | |
parent | 31ee5f8285215545e9de4c5cc0ea169832b5390e (diff) | |
download | smokeping-f160d040a25f4bc6c33787326b581a49c2e38cce.tar.gz smokeping-f160d040a25f4bc6c33787326b581a49c2e38cce.tar.xz |
In cgi mode, do NOT reload the cfg file since this can cause a storm on the webserver. Die instead AFTER working through the current request.
-rw-r--r-- | lib/Smokeping.pm | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm index 0c94b12..c53b3ed 100644 --- a/lib/Smokeping.pm +++ b/lib/Smokeping.pm @@ -1326,7 +1326,8 @@ sub get_detail ($$$$;$){ '--height',$cfg->{Presentation}{detail}{height}, '--width',$cfg->{Presentation}{detail}{width}, '--title',$desc.$from, - '--rigid','--upper-limit', $max->{$s}{$start}, + '--rigid', + '--upper-limit', $max->{$s}{$start}, @log, '--lower-limit',(@log ? ($max->{$s}{$start} > 0.01) ? '0.001' : '0.0001' : '0'), '--vertical-label',$ProbeUnit, @@ -3721,7 +3722,8 @@ sub load_cfg ($;$) { my $cfmod = (stat $cfgfile)[9] || die "ERROR: calling stat on $cfgfile: $!\n"; # when running under speedy this will prevent reloading on every run # if cfgfile has been modified we will still run. - if (not defined $cfg or not defined $probes or $cfg->{__last} < $cfmod ){ + if (not defined $cfg or not defined $probes # or $cfg->{__last} < $cfmod + ){ $cfg = undef; my $parser = get_parser; $cfg = get_config $parser, $cfgfile; @@ -3844,9 +3846,10 @@ POD } sub cgi ($) { + my $cfgfile = shift; $cgimode = 'yes'; umask 022; - load_cfg shift; + load_cfg $cfgfile; my $q=new CGI; initialize_cgilog(); if ($q->param(-name=>'slave')) { # a slave is calling in @@ -3864,6 +3867,10 @@ sub cgi ($) { } display_webpage $cfg,$q; } + if ((stat $cfgfile)[9] > $cfg->{__last}){ + # we die if the cfgfile is newer than our in memory copy + kill -9, $$; + } } |