Skip Menu |

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

Report information
The Basics
Id: 79248
Status: resolved
Priority: 0/
Queue: IO-Async

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

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



Subject: IO::Async::Function->call
Seems that there's a path in IO::Async::Function->call which doesn't return the CPS::Future, which can cause problems in e.g. the resolver used in IO::Async::Connector->connect, since we end up passing undef as one of the parameters to ->needs_all()... seems that we're putting the $task in the queue and will get around to it eventually, so maybe this could just return $task; ? my $worker = $self->_get_worker; if( !$worker ) { my $request = freeze( $args ); push @{ $self->{pending_queue} }, [ $request, $task ]; return; } Tom
On Mon Aug 27 22:02:20 2012, TEAM wrote: Show quoted text
> Seems that there's a path in IO::Async::Function->call which doesn't > return the CPS::Future, which can cause problems in e.g. the resolver > used in IO::Async::Connector->connect, since we end up passing undef as > one of the parameters to ->needs_all()... seems that we're putting the > $task in the queue and will get around to it eventually, so maybe this > could just return $task; ?
Oops. Yes, that'll do it. Patch attached. -- Paul Evans
Subject: rt79248.patch
=== modified file 'lib/IO/Async/Function.pm' --- lib/IO/Async/Function.pm 2012-07-08 22:37:15 +0000 +++ lib/IO/Async/Function.pm 2012-08-28 09:29:00 +0000 @@ -397,7 +397,7 @@ if( !$worker ) { my $request = freeze( $args ); push @{ $self->{pending_queue} }, [ $request, $task ]; - return; + return $task; } $self->_call_worker( $worker, args => $args, $task ); === modified file 't/42function.t' --- t/42function.t 2012-06-26 18:46:24 +0000 +++ t/42function.t 2012-08-28 09:29:00 +0000 @@ -4,7 +4,7 @@ use IO::Async::Test; -use Test::More tests => 42; +use Test::More tests => 44; use Test::Fatal; use Test::Refcount; @@ -104,12 +104,12 @@ my @result; - $function->call( + my $f1 = $function->call( args => [ 1, 2 ], on_return => sub { push @result, shift }, on_error => sub { die "Test failed early - @_" }, ); - $function->call( + my $f2 = $function->call( args => [ 3, 4 ], on_return => sub { push @result, shift }, on_error => sub { die "Test failed early - @_" }, @@ -117,6 +117,9 @@ is( $function->workers, 1, '$function->workers is still 1 after 2 calls' ); + isa_ok( $f1, "CPS::Future", '$f1' ); + isa_ok( $f2, "CPS::Future", '$f2' ); + wait_for { @result == 2 }; is_deeply( \@result, [ 3, 7 ], '@result after both calls return' );
This was released in 0.53 but I forgot to update the ticket. -- Paul Evans