On Thu Feb 20 12:53:16 2014, DAKKAR wrote:
Show quoted text> The Server seems to leak ::Protocol notifiers.
>
> A working (but, again, probably wrong) patch is just to add:
>
> $self->remove_from_parent;
>
> at the end of Net::Async::HTTP::Server::Protocol::on_close.
>
> Hope this helps.
Attached is a nicer fix + unit test.
--
Paul Evans
=== modified file 'lib/Net/Async/HTTP/Server.pm'
--- lib/Net/Async/HTTP/Server.pm 2014-03-26 18:15:55 +0000
+++ lib/Net/Async/HTTP/Server.pm 2014-03-26 18:23:07 +0000
@@ -109,6 +109,15 @@
my $self = shift;
my ( $conn ) = @_;
+ $conn->configure(
+ on_closed => sub {
+ my $conn = shift;
+ $conn->on_closed();
+
+ $conn->remove_from_parent;
+ },
+ );
+
$self->add_child( $conn );
return $conn;
=== modified file 't/01respond.t'
--- t/01respond.t 2014-03-26 17:50:41 +0000
+++ t/01respond.t 2014-03-26 18:23:07 +0000
@@ -47,8 +47,12 @@
}
{
+ my $base_notifiers = $loop->notifiers;
+
my $client = connect_client;
+ is( scalar $loop->notifiers, $base_notifiers + 1, '$loop gains one Notifier after connect' );
+
$client->write(
"GET /path?var=value HTTP/1.1$CRLF" .
"User-Agent: unit-test$CRLF" .
@@ -75,6 +79,12 @@
is_deeply( [ $req->headers ],
[ [ "User-Agent" => "unit-test" ] ],
'$req->headers' );
+
+ $client->close;
+
+ $loop->loop_once( 0.01 ) for 1 .. 3;
+
+ is( scalar $loop->notifiers, $base_notifiers, '$loop back to base level after $client->close' );
}
{