Author: spadkins
Date: Thu Jan 17 08:39:20 2008
New Revision: 10584
Modified:
p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm
Log:
fixed a bug in _push_in_mem which was pushing ACQUIRED entries off the end of
the queue when it shouldn't be
Modified: p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm
==============================================================================
--- p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm (original)
+++ p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm Thu Jan 17 08:39:20 2008
@@ -245,6 +245,10 @@
my ($self, $entry, $release_lowest) = @_;
my $ref = ref($entry);
my $type = "";
+ my $status_attrib = $self->{status_attrib};
+ my $STATUS_ACQUIRED = $self->{STATUS_ACQUIRED};
+ my $STATUS_UNACQUIRED = $self->{STATUS_UNACQUIRED};
+ my $STATUS_UNBUFFERED = $self->{STATUS_UNBUFFERED};
if ($ref eq "ARRAY") {
$type = "ARRAY";
print "PUSHED[M]: [", join("|",@$entry), "]\n" if ($verbose);
@@ -263,7 +267,7 @@
}
else {
CORE::push(@$entries, $entry);
-
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
+ $self->update($entry,[$status_attrib],[$STATUS_UNACQUIRED]);
$num_added = 1;
}
}
@@ -284,15 +288,15 @@
$removed = 1;
}
else {
-
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
+
$self->update($entry,[$status_attrib],[$STATUS_UNACQUIRED]);
splice(@$entries, $i+1, 0, $entry);
$num_added++;
$inserted = 1;
}
}
- if (!$removed) {
+ if (!$removed && ($ent->{$status_attrib} ne
$STATUS_ACQUIRED)) {
$removed_entry = $entries->[$i];
-
$self->update($removed_entry,[$self->{status_attrib}],[$self->{STATUS_UNBUFFERED}]);
+
$self->update($removed_entry,[$status_attrib],[$STATUS_UNBUFFERED]);
splice(@$entries, $i, 1);
$num_added--;
$removed = 1;
@@ -300,7 +304,7 @@
}
else { # this block, we are certain we are not comparing to
ourselves
if ($removed && !$inserted &&
$self->_compare_entries($entry, $ent) > -1) {
-
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
+
$self->update($entry,[$status_attrib],[$STATUS_UNACQUIRED]);
splice(@$entries, $i+1, 0, $entry);
$num_added++;
$inserted = 1;
@@ -318,7 +322,7 @@
last;
}
elsif ($cmp == 1) { # it's lower priority (and different)
-
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
+
$self->update($entry,[$status_attrib],[$STATUS_UNACQUIRED]);
splice(@$entries, $i+1, 0, $entry);
$num_added++;
$inserted = 1;
@@ -327,7 +331,7 @@
}
}
if (!$inserted) {
-
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
+ $self->update($entry,[$status_attrib],[$STATUS_UNACQUIRED]);
unshift(@$entries, $entry);
$num_added++;
}