Sorry for my poor english, let me show it just by code.
flw@waker:~/study$ perl -MPOE -le 'print "$POE::VERSION
$POE::Kernel::VERSION $POE::Session::VERSION"'
1.299 1.299 1.299
flw@waker:~/study$ ./bug.pl
start
call bar ....
inner bar
call bar ....
inner bar
found bug.
call bar ....
call bar ....
call bar ....
flw@waker:~/study$ cat bug.pl
#!/usr/bin/perl
use strict;
use warnings;
use POE;
create POE::Session(
package_states => [
main => [qw( _start foo bar die_on_bug )],
],
);
run POE::Kernel();
sub _start{
print "start\n";
$_[KERNEL]->yield( 'foo' );
}
exit 0;
my $found_bug;
sub foo {
my $sess = $_[KERNEL]->_resolve_session($_[SESSION]) || '';
if ( $_[SESSION] ne $sess and not $found_bug ){
$found_bug = 1;
print "found bug.\n";
$_[KERNEL]->delay( die_on_bug => 3 );
}
print "call bar ....\n";
my $ret = $_[KERNEL]->call( $_[SESSION] => bar => 1 ); # bad
#$_[KERNEL]->call( $_[SESSION] => bar => 1 ) or 1; # bad too
#my @ret = $_[KERNEL]->call( $_[SESSION] => bar => 1 ); # bad too
# $_[KERNEL]->call( $_[SESSION] => bar => 1 ); # good
$_[KERNEL]->delay( foo => 1 );
}
sub bar {
print "inner bar\n";
}
sub die_on_bug {
exit 0;
}
flw@waker:~/study$
Subject: | bug.pl |
#!/usr/bin/perl
use strict;
use warnings;
use POE;
create POE::Session(
package_states => [
main => [qw( _start foo bar die_on_bug )],
],
);
run POE::Kernel();
sub _start{
print "start\n";
$_[KERNEL]->yield( 'foo' );
}
exit 0;
my $found_bug;
sub foo {
my $sess = $_[KERNEL]->_resolve_session($_[SESSION]) || '';
if ( $_[SESSION] ne $sess and not $found_bug ){
$found_bug = 1;
print "found bug.\n";
$_[KERNEL]->delay( die_on_bug => 3 );
}
print "call bar ....\n";
my $ret = $_[KERNEL]->call( $_[SESSION] => bar => 1 ); # bad
#$_[KERNEL]->call( $_[SESSION] => bar => 1 ) or 1; # bad too
#my @ret = $_[KERNEL]->call( $_[SESSION] => bar => 1 ); # bad too
# $_[KERNEL]->call( $_[SESSION] => bar => 1 ); # good
$_[KERNEL]->delay( foo => 1 );
}
sub bar {
print "inner bar\n";
}
sub die_on_bug {
exit 0;
}