summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTobi Oetiker <tobi@oetiker.ch>2008-08-21 22:37:59 +0200
committerTobi Oetiker <tobi@oetiker.ch>2008-08-21 22:37:59 +0200
commit69b86b80304329c14b225613609847922f34ebd7 (patch)
tree9a0784936183a553996cc3d2d636244bef64ef19 /lib
parentf160d040a25f4bc6c33787326b581a49c2e38cce (diff)
downloadsmokeping-69b86b80304329c14b225613609847922f34ebd7.tar.gz
smokeping-69b86b80304329c14b225613609847922f34ebd7.tar.xz
be a bit smarter about handling updates comming in from a client by doing all updates to a name in a single round.
Diffstat (limited to 'lib')
-rw-r--r--lib/Smokeping/Master.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm
index 9a78a31..296935a 100644
--- a/lib/Smokeping/Master.pm
+++ b/lib/Smokeping/Master.pm
@@ -110,9 +110,12 @@ sub save_updates {
my $updates = shift;
# name\ttime\tupdatestring
# name\ttime\tupdatestring
-
+ my %u;
for my $update (split /\n/, $updates){
my ($name, $time, $updatestring) = split /\t/, $update;
+ push @{$u{$name}}, [$time,$updatestring];
+ }
+ for my $name (keys %u){
my $file = slavedatadir($cfg) ."/${name}.${slave}.slave_cache";
if ( ${name} =~ m{(^|/)\.\.($|/)} ){
warn "Skipping update for ${name}.${slave}.slave_cache since ".
@@ -138,7 +141,10 @@ sub save_updates {
$existing = $in;
};
};
- push @{$existing}, [ $slave, $time, $updatestring ];
+ map {
+ push @{$existing}, [ $slave, $_->[0], $_->[1] ];
+ } @{$u{$name}};
+
nstore_fd($existing, $fh);
flock($fh, LOCK_UN);
close $fh;