Author: spadkins
Date: Wed Jun 14 11:27:51 2006
New Revision: 6502
Modified:
p5ee/trunk/App-WorkQueue/lib/App/WorkQueue.pm
p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm
Log:
fixed a bug that occurs during _refill_buffer()
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 Wed Jun 14 11:27:51 2006
@@ -252,6 +252,7 @@
print "PUSHED[M]: {", join("|",%$entry), "}\n" if ($verbose);
}
die "tried to push entry of type [$type] onto queue of type
[$self->{type}]" if ($type ne $self->{type});
+ my $num_added = 0;
my $entries = $self->{data};
my ($removed_entry);
if (!$self->{sort_spec} || $#$entries == -1) {
@@ -261,6 +262,7 @@
else {
CORE::push(@$entries, $entry);
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
+ $num_added = 1;
}
}
else {
@@ -282,6 +284,7 @@
else {
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
splice(@$entries, $i+1, 0, $entry);
+ $num_added++;
$inserted = 1;
}
}
@@ -289,6 +292,7 @@
$removed_entry = $entries->[$i];
$self->update($removed_entry,[$self->{status_attrib}],[$self->{STATUS_UNBUFFERED}]);
splice(@$entries, $i, 1);
+ $num_added--;
$removed = 1;
}
}
@@ -296,6 +300,7 @@
if ($removed && !$inserted &&
$self->_compare_entries($entry, $ent) > -1) {
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
splice(@$entries, $i+1, 0, $entry);
+ $num_added++;
$inserted = 1;
}
}
@@ -313,6 +318,7 @@
elsif ($cmp == 1) { # it's lower priority (and different)
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
splice(@$entries, $i+1, 0, $entry);
+ $num_added++;
$inserted = 1;
last;
}
@@ -321,9 +327,12 @@
if (!$inserted) {
$self->update($entry,[$self->{status_attrib}],[$self->{STATUS_UNACQUIRED}]);
unshift(@$entries, $entry);
+ $num_added++;
}
}
- &App::sub_exit() if ($App::trace);
+
+ &App::sub_exit($num_added) if ($App::trace);
+ return($num_added);
}
sub _analyze_sort_spec {
@@ -474,6 +483,7 @@
$self->_release_resources($entry);
# the following line appears to have been a bug.
#$self->_maintain_queue_buffers("release",$entry);
+ #$self->_maintain_queue_buffers("unacquire",$entry);
}
}
}
@@ -493,6 +503,7 @@
$self->_release_resources($entry);
# the following line appears to have been a bug
#$self->_maintain_queue_buffers("release",$entry);
+ #$self->_maintain_queue_buffers("unacquire",$entry);
}
}
}
Modified: p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm
==============================================================================
--- p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm (original)
+++ p5ee/trunk/App-WorkQueue/lib/App/WorkQueue/Repository.pm Wed Jun 14
11:27:51 2006
@@ -380,10 +380,10 @@
$params->{$status_attrib} = $STATUS_UNBUFFERED;
$new_entries = $db->get_hashes($self->{table}, $params, $columns,
\%options);
}
+ my $num_added = 0;
foreach my $new_entry (@$new_entries) {
- $self->_push_in_mem($new_entry);
+ $num_added += $self->_push_in_mem($new_entry);
}
- my $num_added = $#$new_entries + 1;
&App::sub_exit($num_added) if ($App::trace);
return($num_added);
}
@@ -605,14 +605,14 @@
&App::sub_entry if ($App::trace);
my ($self, $fh, $no_db) = @_;
$fh = \*STDOUT if (!$fh);
- print $fh "ENTRIES IN MEM:\n";
- $self->_print_entries_in_mem($fh);
+ #print $fh "ENTRIES IN MEM:\n";
+ #$self->_print_entries_in_mem($fh);
#if (!$no_db) {
# print $fh "ENTRIES IN DB:\n";
# $self->_print_entries_in_db($fh);
#}
- print $fh "CONSTRAINTS:\n";
- $self->print_constraints($fh);
+ #print $fh "CONSTRAINTS:\n";
+ #$self->print_constraints($fh);
print $fh "STATUS COUNTS:\n";
$self->print_status_counts($fh);
print $fh "RESOURCE COUNTS:\n";