Permalink
Browse files

port => undef means it can bind to any port like it used to do

  • Loading branch information...
1 parent a2f3cc9 commit 8b23cdbb424c3b37570f2a3adbbc8127ec2051d3 @miyagawa committed Sep 10, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/Twiggy/Server.pm
View
@@ -41,7 +41,7 @@ sub new {
sub start_listen {
my ($self, $app) = @_;
- my @listen = @{$self->{listen} || [ ($self->{host} || '') . ":$self->{port}" ]};
+ my @listen = @{$self->{listen} || [ ($self->{host} || '') . ":" . ($self->{port} || 0) ]};
for my $listen (@listen) {
push @{$self->{listen_guards}}, $self->_create_tcp_server($listen, $app);
}
@@ -67,13 +67,14 @@ sub _create_tcp_server {
if ($listen =~ /:\d+$/) {
($host, $port) = split /:/, $listen;
$host = undef if $host eq '';
+ $port = undef if $port == 0;
$is_tcp = 1;
} else {
$host = "unix/";
$port = $listen;
}
- return tcp_server $host, $port, $self->_accept_handler($app, $is_tcp),
+ return tcp_server $host, $port, $self->_accept_handler($app, $is_tcp),
$self->_accept_prepare_handler;
}

0 comments on commit 8b23cdb

Please sign in to comment.