summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/Master.pm
diff options
context:
space:
mode:
authorTobi Oetiker <tobi@oetiker.ch>2007-08-21 21:40:36 +0200
committerTobi Oetiker <tobi@oetiker.ch>2007-08-21 21:40:36 +0200
commitd011593577316a9782b6dca8cc4d09dc0b98aba3 (patch)
treeaece59f839fa05537ad8c4c6e7ad67f4f5d1a563 /lib/Smokeping/Master.pm
parentba4e1c581d671ca47bed2ba19bae37849c27a935 (diff)
downloadsmokeping-d011593577316a9782b6dca8cc4d09dc0b98aba3.tar.gz
smokeping-d011593577316a9782b6dca8cc4d09dc0b98aba3.tar.xz
improve handling of storable for for communication between cgi and daemon
Diffstat (limited to 'lib/Smokeping/Master.pm')
-rw-r--r--lib/Smokeping/Master.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm
index 567324f..10333a8 100644
--- a/lib/Smokeping/Master.pm
+++ b/lib/Smokeping/Master.pm
@@ -103,14 +103,14 @@ sub save_updates {
warn "Skipping update for ${name}.slave_cache since $cfg->{General}{datadir}/${name}.rrd does not exist in the local data structure. Make sure you run the smokeping daemon. ($cfg->{General}{datadir})\n";
} elsif ( open (my $hand, '+>>', $file) ) {
if ( flock $hand, LOCK_EX ){
- my $existing;
+ my $existing = [];
if ( tell $hand > 0 ){
seek $hand, 0,0;
eval { $existing = fd_retrieve $hand };
- if ($@) { #error
+ if ($@) { #error
warn "Loading $file: $@";
$existing = [];
- }
+ }
};
push @{$existing}, [ $slave, $time, $updatestring];
seek $hand, 0,0;
@@ -144,7 +144,8 @@ sub get_slaveupdates {
warn "Loading $file: $@";
return;
}
- unlink $file;
+ seek $hand, 0,0;
+ truncate $hand, 0;
flock $hand, LOCK_UN;
} else {
warn "Could not lock $file. Can't load data.\n";