From 09a4089d927f4c63fdab1b8bded2a73ac398d412 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Sat, 30 Aug 2008 13:09:37 +0000 Subject: properly fix the handling of multiple writes to the cache file --- lib/Smokeping/Master.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/Smokeping') diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm index e2c50fd..1a12427 100644 --- a/lib/Smokeping/Master.pm +++ b/lib/Smokeping/Master.pm @@ -1,7 +1,7 @@ # -*- perl -*- package Smokeping::Master; use Data::Dumper; -use Storable qw(nstore_fd dclone fd_retrieve); +use Storable qw(nstore dclone fd_retrieve); use strict; use warnings; use Fcntl qw(:flock); @@ -143,8 +143,8 @@ sub save_updates { map { push @{$existing}, [ $slave, $_->[0], $_->[1] ]; } @{$u{$name}}; - seek $fh, 0, 0; - nstore_fd($existing, $fh); + nstore($existing, $file.$$); + rename $file.$$,$file; flock($fh, LOCK_UN); close $fh; last; -- cgit v1.2.3-24-g4f1b