From f160d040a25f4bc6c33787326b581a49c2e38cce Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Wed, 13 Aug 2008 20:13:37 +0000 Subject: 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. --- lib/Smokeping.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib') 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, $$; + } } -- cgit v1.2.3-24-g4f1b