Subject: | _child(lose) event fired for a session detached from its parent |
When a session is detached from its parent in its _start event
(POE::Kernel->detach_myself), no _child events should be fired to the
session which called the POE::Session->create constructor.
Currently no _child(create) is fired. This is good.
But a _child(lose) is fired. This is unexpected. And inconsistent as we
are in a case where we have a _child(lose) without a corresponding
_child(create/gain).
This bug has been discussed on the mailing list on 2009-11-19.
A complete test case is attached.
Verified on POE 1.006 and 1.280 ( other releases not tested).
--
Olivier Mengué - http://o.mengue.free.fr/
Subject: | _child-from-detached-session.t |
use strict;
use warnings;
use Test::More tests => 7;
use POE;
my $_child_fired = 0;
POE::Session->create(
inline_states => {
_start => sub {
$_[KERNEL]->alias_set('First');
pass "_start First";
POE::Session->create(
inline_states => {
_start => sub {
$_[KERNEL]->alias_set('Second');
pass "_start Second";
},
},
);
POE::Session->create(
inline_states => {
_start => sub {
$_[KERNEL]->alias_set('Detached');
pass "_start Detached";
diag "Detaching session 'Detached' from its parent";
$_[KERNEL]->detach_myself;
},
},
);
},
_child => sub {
$_child_fired++;
ok($_[KERNEL]->alias_list($_[ARG1]) ne 'Detached',
"$_[STATE]($_[ARG0]) fired for ".$_[KERNEL]->alias_list($_[ARG1]->ID));
},
},
);
POE::Kernel->run();
pass "_child not fired for session detached in _start" unless $_child_fired != 2;
pass "Stopped";