From: Matt S Trout Date: Tue, 29 Nov 2011 21:33:50 +0000 (+0000) Subject: better cleanup X-Git-Tag: v0.001001~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55cf7075634875c981085d7f128b9cdd31554fd9;p=scpubgit%2FTak-Daemon.git better cleanup --- diff --git a/lib/Tak/Daemon/ListenerService.pm b/lib/Tak/Daemon/ListenerService.pm index 3ef2a8b..f9738ce 100644 --- a/lib/Tak/Daemon/ListenerService.pm +++ b/lib/Tak/Daemon/ListenerService.pm @@ -55,6 +55,9 @@ sub _build__start_in_progress { on_accept => sub { $self->setup_connection($_[0]); }, + on_accept_error => sub { + $self->handle_stop; + }, ); $start{start} = sub {}; # delete yourself }; @@ -67,6 +70,7 @@ sub handle_stop { # there's probably something more intelligent to do here, but meh die failure => 'starting' if $self->state eq 'starting'; Tak->loop->remove($self->clear_listener); + unlink($self->socket_location); $self->state('down'); return 'stopped'; } @@ -76,6 +80,7 @@ sub DEMOLISH { return if $gd; if (my $l = $self->listener) { $l->get_loop->remove($l); + unlink($self->socket_location); } } @@ -85,7 +90,7 @@ sub setup_connection { my $connection; $connection = Tak::ConnectionService->new( read_fh => $socket, write_fh => $socket, - listening_service => $self->router, + listening_service => $self->router->clone, on_close => sub { delete $conn_set->{$connection} } ); $conn_set->{$connection} = $connection;