Subject: | Weird FH generation issue. (fix attached) |
After connecting to Spread, the module creates a filehandle associated
with the Spread value, so that the ReadWrite wheel has a handle to
watch.
The code sez:
## SpreadClient.pm, line 151:
open $_[HEAP]->{'FH'}, '<&=', $mbox;
This sometimes fails!!! In POE's internals, there is:
my $handle = fileno($fh)
and when FH creation fails, it cascades into a really ugly problem.
The fix is simple:
## SpreadClient.pm, line 151:
open $_[HEAP]->{'FH'}, '<&=', $mbox
until $_[HEAP]->{'FH'} && fileno($_[HEAP]->{'FH'});
The patch I've attached does the same thing but warns.
My testing shows, it warns EVERY TIME!! ?
Suggesting perhaps the call to fileno($fh) works "after a bit" ?
Subject: | spreadclient_badfh.patch |
--- POE-Component-SpreadClient-0.09/lib/POE/Component/SpreadClient.pm 2011-02-02 15:17:15.000000000 -0800
+++ SpreadClient-working/lib/POE/Component/SpreadClient.pm 2011-02-08 14:07:45.000000000 -0800
@@ -4,7 +4,7 @@
# Initialize our version $LastChangedRevision: 9 $
use vars qw( $VERSION );
-$VERSION = '0.09';
+$VERSION = '0.09_02';
# Load our stuff
use 5.006; # to silence Perl::Critic's Compatibility::ProhibitThreeArgumentOpen
@@ -148,7 +148,14 @@
$_[HEAP]->{'MBOX'} = $mbox;
# Create a FH to feed into Wheel::ReadWrite
+ until ($_[HEAP]->{'FH'} && fileno($_[HEAP]->{'FH'})) {
open $_[HEAP]->{'FH'}, '<&=', $mbox;
+ warn "SpreadClient: bad fh!!! retrying";
+ }
+
+ # production version:
+ # open $_[HEAP]->{'FH'}, '<&=', $mbox until $_[HEAP]->{'FH'} && fileno($_[HEAP]->{'FH'});
+
# Finally, create the wheel!
$_[HEAP]->{'WHEEL'} = POE::Wheel::ReadWrite->new(