From 69b86b80304329c14b225613609847922f34ebd7 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Thu, 21 Aug 2008 20:37:59 +0000 Subject: be a bit smarter about handling updates comming in from a client by doing all updates to a name in a single round. --- lib/Smokeping/Master.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') 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; -- cgit v1.2.3-24-g4f1b