From 5316058ba817ef00e98d392328e7c9c9391df47c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 17 May 2014 20:42:19 +0100 Subject: [PATCH] remove unecessary scrub subroutine --- Netdisco/lib/App/Netdisco/Daemon/LocalQueue.pm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Daemon/LocalQueue.pm b/Netdisco/lib/App/Netdisco/Daemon/LocalQueue.pm index 465b0417..13834a3f 100644 --- a/Netdisco/lib/App/Netdisco/Daemon/LocalQueue.pm +++ b/Netdisco/lib/App/Netdisco/Daemon/LocalQueue.pm @@ -5,7 +5,7 @@ use Dancer::Plugin::DBIC 'schema'; use base 'Exporter'; our @EXPORT = (); -our @EXPORT_OK = qw/ add_jobs capacity_for take_jobs reset_jobs scrub_jobs /; +our @EXPORT_OK = qw/ add_jobs capacity_for take_jobs reset_jobs/; our %EXPORT_TAGS = ( all => \@EXPORT_OK ); schema('daemon')->deploy; @@ -28,10 +28,11 @@ sub capacity_for { sub take_jobs { my ($wid, $type, $max) = @_; + return () unless $wid > 1; $max ||= 1; - # asking for more jobs means the current ones are done - scrub_jobs($wid); + debug "deleting completed jobs by worker $wid"; + $queue->search({wid => $wid})->delete; debug "searching for $max new jobs for worker $wid (type $type)"; my $rs = $queue->search( @@ -49,6 +50,7 @@ sub take_jobs { return \@rows; } +# not used by workers, only the daemon when reinitializing a worker sub reset_jobs { my ($wid) = @_; debug "resetting jobs owned by worker $wid to be available"; @@ -57,11 +59,4 @@ sub reset_jobs { ->update({wid => 0}); } -sub scrub_jobs { - my ($wid) = @_; - debug "deleting dangling jobs owned by worker $wid"; - return unless $wid > 1; - $queue->search({wid => $wid})->delete; -} - 1;