diff options
author | Tobi Oetiker <tobi@oetiker.ch> | 2008-08-21 22:37:59 +0200 |
---|---|---|
committer | Tobi Oetiker <tobi@oetiker.ch> | 2008-08-21 22:37:59 +0200 |
commit | 69b86b80304329c14b225613609847922f34ebd7 (patch) | |
tree | 9a0784936183a553996cc3d2d636244bef64ef19 /lib/Smokeping | |
parent | f160d040a25f4bc6c33787326b581a49c2e38cce (diff) | |
download | smokeping-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/Smokeping')
-rw-r--r-- | lib/Smokeping/Master.pm | 10 |
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; |