On Jan 3, 2007, at 2:24 PM, Rocco Caputo wrote:
The sig() watchers are throwing "signal_shutdown" events to the
wrong session. Your start_server() callback is executed within the
context of the main listener session. PackageStates are used to
customize each connection's session, however, so the signal_shutdown
() handler lives elsewhere.
You can work around this by putting the signal handling in one
session, separate from the TCP server component's sessions.
Something like this untested code:
I needed one minor addition
POE::Session->create(
inline_states => {
_start => sub {
my $kernel = $_[KERNEL];
$kernel->set_alias('signal_hander'); # prevent premature
garbage collection
$kernel->sig( INT => 'signal_shutdown' );
$kernel->sig( TERM => 'signal_shutdown' );
$kernel->sig( HUP => 'signal_shutdown' );
},
signal_shutdown => sub {
my ($kernel, $signal) = @_[KERNEL, ARG0];
debug ("got $signal signal\n");
$kernel->post( server => "shutdown" );
$kernel->sig_handled;
},
},
);
With that change, it appears to be working as I wanted.
Thanks!
-kevin