summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping
diff options
context:
space:
mode:
authorTobi Oetiker <tobi@oetiker.ch>2007-12-13 21:43:15 +0100
committerTobi Oetiker <tobi@oetiker.ch>2007-12-13 21:43:15 +0100
commit1f7c876a44f4bcb28affa098c283979b2bc08f32 (patch)
treed33e2b7d1844fa5adf29fc8871a35613cacbde84 /lib/Smokeping
parent41a1b1a239810f5d06e286331f8a7dd607224cfe (diff)
downloadsmokeping-1f7c876a44f4bcb28affa098c283979b2bc08f32.tar.gz
smokeping-1f7c876a44f4bcb28affa098c283979b2bc08f32.tar.xz
use different syntax to open and lock client cache
Diffstat (limited to 'lib/Smokeping')
-rw-r--r--lib/Smokeping/Master.pm10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm
index 4fcdaad..590e75e 100644
--- a/lib/Smokeping/Master.pm
+++ b/lib/Smokeping/Master.pm
@@ -101,12 +101,12 @@ sub save_updates {
my $file = $cfg->{General}{datadir}."/${name}.slave_cache";
if ( ! -f $cfg->{General}{datadir}."/${name}.rrd" ){
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) ) {
+ }
+ elsif ( open (my $hand, '+<', $file) ) {
for (my $i = 10; $i < 0; $i--){
if ( flock $hand, LOCK_EX ){
my $existing = [];
- if ( tell $hand > 0 ){
- seek $hand, 0,0;
+ if ( (stat($hand))[7] > 0 ){
eval { $existing = fd_retrieve $hand };
if ($@) { #error
warn "Loading $file: $@";
@@ -121,14 +121,14 @@ sub save_updates {
last;
} else {
warn "Could not lock $file. Trying again for $i rounds.\n";
- sleep 1;
+ sleep rand(3);
}
}
close $hand;
} else {
warn "Could not update $file: $!";
}
- }
+ }
};
=head3 get_slaveupdates