Skip Menu |

This queue is for tickets about the IO-Async-Loop-POE CPAN distribution.

Report information
The Basics
Id: 101725
Status: open
Priority: 0/
Queue: IO-Async-Loop-POE

People
Owner: Nobody in particular
Requestors: gbjk [...] thermeon.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: POE ASSERT_DEFAULT warnings, and references
Paul, When running under POE_ASSERT_DEFAULT, I encountered issues with timers being removed that didn't exist. I also found failures on a lack of _stop. The attached patch fixes that, by not doing alarm_remove unless $timer_id is defined. Whilst there, I also spotted a few issues which caused POE's reference tracker to get it's knickers in a twist, as well as a lack of aliasing. With an alias set and removed, there's no need to keep a reference to the kernel, or to the session itself, and doing so creates circular references which POE_TRACE_DEFAULT will highlight as keeping this session alive longer than it should be. I think the kernel reference and the session reference weren't the end of the world, but I had to fix them both before I could work out why the session wasn't going down. Sorry I don't have tests for this stuff, but I wanted to provide the fix up front.
Subject: IO-Async-Loop-POE-0.05.patch
diff -Naurb ../IO-Async-Loop-POE-0.05.orig/lib/IO/Async/Loop/POE.pm ./lib/IO/Async/Loop/POE.pm --- ../IO-Async-Loop-POE-0.05.orig/lib/IO/Async/Loop/POE.pm 2015-01-25 13:14:18.586713766 +0000 +++ ./lib/IO/Async/Loop/POE.pm 2015-01-25 13:15:03.746712384 +0000 @@ -73,13 +73,16 @@ my $self = $class->SUPER::__new( %args ); - my $kernelref = \($self->{kernel} = undef); + $self->{alias} = 'IO::Async'; - $self->{session} = POE::Session->create( + POE::Session->create( inline_states => { _start => sub { - $_[KERNEL]->alias_set( "IO::Async" ); - $$kernelref = $_[KERNEL]; + $_[KERNEL]->alias_set( $self->{alias} ); + }, + + _stop => sub { + $_[KERNEL]->alias_remove( $self->{alias} ); }, invoke => sub { @@ -108,6 +111,7 @@ $_[KERNEL]->delay_set( invoke => $_[ARG0], $_[ARG1] ); }, alarm_remove => sub { + warn "alarm: ".$_[ARG0]; $_[KERNEL]->alarm_remove( $_[ARG0] ); }, @@ -140,7 +144,7 @@ sub _call { my $self = shift; - $self->{kernel}->call( $self->{session}, @_ ); + POE::Kernel->call( $self->{alias}, @_ ); } sub loop_once @@ -149,7 +153,7 @@ my ( $timeout ) = @_; if( defined $timeout and $timeout == 0 ) { - $self->{kernel}->run_one_timeslice; + POE::Kernel->run_one_timeslice; return; } @@ -158,9 +162,11 @@ $timer_id = $self->_call( delay_set => $timeout, sub { } ); } - $self->{kernel}->run_one_timeslice; + POE::Kernel->run_one_timeslice; + if ( $timer_id ){ $self->_call( alarm_remove => $timer_id ); + } } sub watch_io
That first patch had the issue of introducing an extra reference to $self, which makes the tests fail. Attached is a revised patch which doesn't.
Subject: IO-Async-Loop-POE-0.05.patch2
Download IO-Async-Loop-POE-0.05.patch2
application/octet-stream 1.5k

Message body not shown because it is not plain text.