Subject: | cancel_all() generates warnings on simplex messaged |
Thread::Queue::Duplex is generateing the following error when you call
$q->cancel_all() on a queue with simplex messages:
"Use of uninitialized value in delete at /usr/lib/perl5/site_perl/5.8.5/Thread/Queue/Duplex.pm line 1478."
You can run the following simple script to recreate the errors:
======================================================================
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Queue::Duplex;
print "enqueue() works fine on cancel_all()\n";
my $q_enqueue = Thread::Queue::Duplex->new();
$q_enqueue->enqueue("foo");
$q_enqueue->enqueue("bar");
$q_enqueue->enqueue("ha");
$q_enqueue->cancel_all();
print "enqueue_simplex() seems to mess up on cancel_all()\n";
my $q_enqueue_simplex = Thread::Queue::Duplex->new();
$q_enqueue_simplex->enqueue_simplex("foo");
$q_enqueue_simplex->enqueue_simplex("bar");
$q_enqueue_simplex->enqueue_simplex("ha");
$q_enqueue_simplex->cancel_all();
======================================================================
I attached a simple patch file that should be applied to Duplex.pm.
--- Duplex.pm.ORI 2006-01-06 10:50:57.820121158 -0800
+++ Duplex.pm 2006-01-06 10:57:07.590690569 -0800
@@ -1474,7 +1474,9 @@
# setting their IDs to -1
#
- delete $obj->[TQD_MARKS]{$_->[0]},
- $_->[0] = -1
- foreach (@{$obj->[TQD_Q]});
+ foreach (@{$obj->[TQD_Q]}) {
+ delete $obj->[TQD_MARKS]{$_->[0]}
+ if ( defined($_->[0]) );
+ $_->[0] = -1;
+ }
#
# how will we cancel inprogress requests ??