Skip to content

Commit

Permalink
Fix POE::NFA's stop() method. Previously it was using POE::Kernel's
Browse files Browse the repository at this point in the history
session_free() method, which was recently renamed.
  • Loading branch information
rcaputo committed Apr 29, 2003
1 parent d527709 commit 20b26bb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/POE/Kernel.pm
Expand Up @@ -2549,8 +2549,13 @@ sub _dispatch_event {
# at once. No, probably not, since GC triggers _stop, which may
# trigger other GC. -><-

# Need to test $session for existence because POE::NFA->stop() may
# have discarded it already. -><- This is rapidly becoming a
# mess, and some sort of mark/sweep may clean it up.

if ($type & ET_USER) {
$self->_data_ses_collect_garbage($session);
$self->_data_ses_collect_garbage($session)
if $self->_data_ses_exists($session);
$self->_data_ses_collect_garbage($source_session)
if ( $session != $source_session and
$self->_data_ses_exists($source_session)
Expand Down
2 changes: 1 addition & 1 deletion lib/POE/NFA.pm
Expand Up @@ -224,7 +224,7 @@ sub _invoke_state {

# Stop request has come through the queue. Shut us down.
if ($event eq NFA_EN_STOP) {
$POE::Kernel::poe_kernel->session_free( $self );
$POE::Kernel::poe_kernel->_data_ses_free( $self );
return;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/23_nfa.t
Expand Up @@ -56,6 +56,18 @@ POE::NFA->spawn
},
)->goto_state( initial => 'start' ); # enter the initial state

### This NFA uses the stop() method. Gabriel Kihlman discovered that
### POE::NFA lags behind POE::Kernel after 0.24, and stop() wasn't
### fixed to use the new _data_ses_free() method of POE::Kernel.

POE::NFA->spawn
( inline_states =>
{ initial =>
{ start => sub { $_[MACHINE]->stop() }
}
}
)->goto_state(initial => 'start');

### A plain session to interact with the switch. It's in its own
### package to avoid conflicting constants. This simulates a causal
### observer who pushes the light's button over and over, watching it
Expand Down

0 comments on commit 20b26bb

Please sign in to comment.