Last patch wasn't quite right, because RW_GotPacket was written to
ONLY read one packet from the filter, regardless of how many had been
delivered.
This patch includes: multi_read patch to Driver, and bugfix to
Component to process all messages delivered.
diff -urw POE-Component-SpreadClient-0.08/lib/POE/Component/SpreadClient.pm POE-Component-SpreadClient-0.09/lib/POE/Component/SpreadClient.pm
--- POE-Component-SpreadClient-0.08/lib/POE/Component/SpreadClient.pm 2009-02-01 18:47:35.000000000 -0800
+++ POE-Component-SpreadClient-0.09/lib/POE/Component/SpreadClient.pm 2011-02-01 20:32:26.000000000 -0800
@@ -4,7 +4,7 @@
# Initialize our version $LastChangedRevision: 9 $
use vars qw( $VERSION );
-$VERSION = '0.08';
+$VERSION = '0.09';
# Load our stuff
use 5.006; # to silence Perl::Critic's Compatibility::ProhibitThreeArgumentOpen
@@ -438,7 +438,8 @@
}
sub RW_GotPacket : State {
- my( $type, $sender, $groups, $mess_type, $endian, $message ) = @{ @{ $_[ARG0] }[0] };
+ for my $packet ( @{ $_[ARG0] } ) {
+ my( $type, $sender, $groups, $mess_type, $endian, $message ) = @{ $packet };
# Check for disconnect
if ( ! defined $type ) {
@@ -523,6 +524,7 @@
}
}
+ }
# All done!
return;
}
diff -urw POE-Component-SpreadClient-0.08/lib/POE/Driver/SpreadClient.pm POE-Component-SpreadClient-0.09/lib/POE/Driver/SpreadClient.pm
--- POE-Component-SpreadClient-0.08/lib/POE/Driver/SpreadClient.pm 2011-02-01 20:37:53.000000000 -0800
+++ POE-Component-SpreadClient-0.09/lib/POE/Driver/SpreadClient.pm 2011-02-01 20:38:41.000000000 -0800
@@ -4,11 +4,13 @@
# Our version stuff
use vars qw( $VERSION );
-$VERSION = '0.08';
+$VERSION = '0.09';
# Import some stuff
use Spread;
+use constant MAX_READS => 256;
+
sub new {
my $type = shift;
my $mbox = shift;
@@ -18,9 +20,18 @@
sub get {
my $self = shift;
+ my $reads_performed = 1;
+ my @buf = ();
+
+ # read once:
+ push @buf, [ Spread::receive( $$self ) ];
+
+ # Spread::poll returns 0 if no messages pending;
+ while(Spread::poll($$self) and ++$reads_performed <= MAX_READS) {
+ push @buf, [ Spread::receive( $$self ) ];
+ }
- # this returns all undef if we're disconnected
- return [ [ Spread::receive( $$self ) ] ];
+ return [ @buf ];
}
1;