Skip to content

Commit

Permalink
move socket listen to start_listen, and let SS override that method i…
Browse files Browse the repository at this point in the history
…nstead of register_service
  • Loading branch information
lestrrat committed Feb 19, 2010
1 parent d0b0904 commit c162a31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 8 additions & 3 deletions lib/Twiggy/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ sub new {
}, $class;
}

sub register_service {
my($self, $app) = @_;

sub start_listen {
my ($self, $app) = @_;
my @listen = @{$self->{listen} || [ ($self->{host} || '') . ":$self->{port}" ]};
for my $listen (@listen) {
push @{$self->{listen_guards}}, $self->_create_tcp_server($listen, $app);
}
}

sub register_service {
my($self, $app) = @_;

$self->start_listen($app);

$self->{exit_guard} = AE::cv {
# Make sure that we are not listening on a socket anymore, while
Expand Down
9 changes: 1 addition & 8 deletions lib/Twiggy/Server/SS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use AnyEvent::Util qw(fh_nonblocking guard);
use AnyEvent::Socket qw(format_address);
use Server::Starter qw(server_ports);

sub register_service {
sub start_listen {
my ($self, $app) = @_;

if (Twiggy::Server::DEBUG() && $self->{listen}) {
Expand All @@ -25,13 +25,6 @@ sub register_service {

# overwrite, just in case somebody wants to refer to it afterwards
$self->{listen} = \@listen;

$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_ss_tcp_server {
Expand Down

0 comments on commit c162a31

Please sign in to comment.