ConnectionPool: avoid undefined behavior for hash iteration
[MogileFS-Server.git] / lib / Mogstored / HTTPServer.pm
blob96661ff86bf61f551e5dd21c277f0a35aedaf2f8
1 package Mogstored::HTTPServer;
2 use strict;
3 sub new {
4 my ($class, %opts) = @_;
5 my $self = bless {}, $class;
6 $self->{docroot} = delete $opts{docroot};
7 $self->{listen} = delete $opts{listen};
8 $self->{maxconns} = delete $opts{maxconns};
9 $self->{bin} = delete $opts{bin};
10 $self->{include} = delete $opts{include};
11 die "unknown opts" if %opts;
12 return $self;
15 sub start {
16 my $self = shift;
17 die "start not implemented for $self";
20 sub pre_daemonize {
21 my $self = shift;
24 sub post_daemonize {
25 my $self = shift;
28 sub listen_port {
29 my $self = shift;
30 my $port = $self->{listen};
31 $port =~ s/^.+://;
32 die "not numeric port?" unless $port =~ /^\d+$/;
33 return $port;
36 sub bind_ip {
37 my $self = shift;
38 if ($self->{listen} =~ /^(.+):\d+$/) {
39 return $1;
40 } elsif ($self->{listen} =~ /^\d+$/) {
41 return "0.0.0.0";
42 } else {
43 die "Bogus listen value?";