Browse files

Destroy the listen guards when $cv is signaled. This closes the incom…

…ing socket, so you won't have new connections arriving while the rest of the server flushes events and shuts down
  • Loading branch information...
1 parent eee3325 commit 78f0dd10920d6c049429b116fb2e6e1161575840 @lestrrat lestrrat committed Feb 16, 2010
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/Twiggy/Server.pm
View
6 lib/Twiggy/Server.pm
@@ -527,7 +527,11 @@ sub run {
my $self = shift;
$self->register_service(@_);
- my $exit = $self->{exit_guard} = AE::cv;
+ 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 };

0 comments on commit 78f0dd1

Please sign in to comment.