Subject: | CONNECT hangs (goes off into limbo on Windows |
Attached script works fine on Linux.
On Windows it just Hangs.
The following change in SimpleDBI.pm
'Program' => \&POE::Component::SimpleDBI::SubProcess::main(),
to
'Program' => sub { POE::Component::SimpleDBI::SubProcess::main() },
connects successfully.
On failed connection there are other errors:
E/Component/SimpleDBI.pm line 1150.
POE::Component::SimpleDBI did not get a hash from the SubProcess ( ) at
C:/Perl/site/lib/POE/Component/SimpleDBI.pm line 1150.
POE::Component::SimpleDBI got an read error 10054: Unknown error
Subject: | SimpleDBI_test.pl |
#!perl -w
use strict;
use warnings;
sub POE::Component::SimpleDBI::DEBUG() {1}
use POE qw( Component::SimpleDBI );
POE::Session->create
( inline_states => { _start => \&start,
doConn => \&doConn,
_stop => sub {warn "_stop"},
conn_handler => \&conn_handler,
DBconn => \&DBconn,
DBerr => sub {
warn "DBerr at ", scalar localtime(), "\n";
$_[HEAP]->{DBerr}++;
},
DBresults => sub {
warn "DBresults at ", scalar localtime(), "\n";
}
},
);
warn "run\n";
$poe_kernel->run;
sub DBconn {
print "DBconn at ", scalar localtime(), "\n";
$_[KERNEL]->post( 'SimpleDBI',
arrayhash => {
sql => 'SELECT unix_timestamp()',
event => 'DBresults',
}
);
}
sub start {
warn "_start\n";
$_[KERNEL]->alias_set('mySession');
$_[HEAP]->{SimpleDBI} = POE::Component::SimpleDBI->new( 'SimpleDBI' );
$_[KERNEL]->yield('doConn');
}
sub doConn {
warn "doConn\n";
my $dsn;
my ($user, $pass);
$dsn = "dbi:mysql:database=test;host=localhost;port=3306";
($user, $pass) = ( 'auser', 'apass' );
$_[KERNEL]->post( 'SimpleDBI', 'CONNECT',
DSN => $dsn,
USERNAME => $user,
PASSWORD => $pass,
EVENT => 'conn_handler',
SESSION => 'mySession',
NOW => 1,
);
}
sub conn_handler {
my $result = $_[ARG0];
if ($result ->{ERROR}) {
warn "conn_handler (ERROR)\n";
sleep (1);
$_[KERNEL]->yield('doConn');
} elsif ($result ->{GONE}) {
warn "conn_handler (GONE)\n";
} else {
warn "conn_handler (Success)\n";
}
}