From 2476159764b327587c3471b9dde4d34592921b4a Mon Sep 17 00:00:00 2001 From: "Andreas J. Koenig" Date: Mon, 21 Jun 2010 05:09:56 +0200 Subject: [PATCH] minirefactoring to find out what needs be done to run batches; tests still pass --- Todo | 6 ++++++ lib/File/Rsync/Mirror/Recentfile.pm | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Todo b/Todo index e916411..e5caeea 100644 --- a/Todo +++ b/Todo @@ -13,6 +13,12 @@ have no way to force dirty and fast operation yet but we need it for init. + Irritating the bootstrapping race: the order {(1) fill initial + array, (2) start server} leaves the need for an fsck to cover the time + between 1 and 2. Given that regular fsck is needed in any case the price + is not high but still doesn't give a warm feeling. Maybe starting the + server will by itself do an fsck? + 2010-06-15 Andreas J. Koenig * remove the wild alpha alerts and say, it is alpha but parts of it are diff --git a/lib/File/Rsync/Mirror/Recentfile.pm b/lib/File/Rsync/Mirror/Recentfile.pm index 4a75e0d..1c3160b 100644 --- a/lib/File/Rsync/Mirror/Recentfile.pm +++ b/lib/File/Rsync/Mirror/Recentfile.pm @@ -1974,6 +1974,15 @@ sub _epoch_monotonically_increasing { } sub update { my($self,$path,$type,$dirty_epoch) = @_; + $self->lock; + my $ctx = $self->_locked_batch_update([{path=>$path,type=>$type,epoch=>$dirty_epoch}]); + $self->write_recent($ctx->{recent}) if $ctx->{something_done}; + $self->_assert_symlink; + $self->unlock; +} +sub _locked_batch_update { + my($self,$batch) = @_; + my($path,$type,$dirty_epoch) = @{$batch->[0]}{qw(path type epoch)}; if (defined $path or defined $type or defined $dirty_epoch) { die "update called without path argument" unless defined $path; die "update called without type argument" unless defined $type; @@ -1988,7 +1997,6 @@ sub update { $path = $self->$canonmeth($path); } my $lrd = $self->localroot; - $self->lock; # you must calculate the time after having locked, of course my $now = Time::HiRes::time; my $interval = $self->interval; @@ -2050,10 +2058,7 @@ sub update { } $something_done = 1; } - - $self->write_recent($recent) if $something_done; - $self->_assert_symlink; - $self->unlock; + return {something_done=>$something_done,recent=>$recent}; } sub _update_with_dirty_epoch { -- 2.11.4.GIT