Permalink
Browse files

Move the exit_guard to register_service so AE::cv->recv (without ->ru…

…n) would work.
  • Loading branch information...
1 parent 2d065bd commit 0642ce7b7fb5313b697a6fd0760616a5d048f366 @miyagawa committed Feb 18, 2010
Showing with 11 additions and 10 deletions.
  1. +2 −1 lib/Twiggy.pm
  2. +9 −9 lib/Twiggy/Server.pm
View
@@ -24,7 +24,8 @@ See C<twiggey -h> for more details.
port => $port,
);
$server->register_service($app);
- $server->run;
+
+ AE::cv->recv;
=head1 DESCRIPTION
View
@@ -46,6 +46,13 @@ sub register_service {
for my $listen (@listen) {
push @{$self->{listen_guards}}, $self->_create_tcp_server($listen, $app);
}
+
+ $self->{exit_guard} = AE::cv {
+ # Make sure that we are not listening on a socket anymore, while
+ # other events are being flushed
+ delete $self->{listen_guards};
+ };
+ $self->{exit_guard}->begin;
}
sub _create_tcp_server {
@@ -544,15 +551,8 @@ sub run {
my $self = shift;
$self->register_service(@_);
- my $exit = $self->{exit_guard} = AE::cv {
- # Make sure that we are not listening on a socket anymore, while
- # other events are being flushed
- delete $self->{listen_guards};
- };
- $exit->begin;
-
- my $w; $w = AE::signal QUIT => sub { $exit->end; undef $w };
- $exit->recv;
+ my $w; $w = AE::signal QUIT => sub { $self->{exit_guard}->end; undef $w };
+ $self->{exit_guard}->recv;
}
package Twiggy::Writer;

0 comments on commit 0642ce7

Please sign in to comment.