use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
STDOUT->autoflush(1);
STDERR->autoflush(1);
-require Danga::Socket;
+require PublicInbox::DS;
require POSIX;
require PublicInbox::Listener;
require PublicInbox::ParentPipe;
# killing again terminates immediately:
exit unless @listeners;
- $_->close foreach @listeners; # call Danga::Socket::close
+ $_->close foreach @listeners; # call PublicInbox::DS::close
@listeners = ();
$reason->close if ref($reason) eq 'PublicInbox::ParentPipe';
my $proc_name;
my $warn = 0;
# drop idle connections and try to quit gracefully
- Danga::Socket->SetPostLoopCallback(sub {
+ PublicInbox::DS->SetPostLoopCallback(sub {
my ($dmap, undef) = @_;
my $n = 0;
my $now = clock_gettime(CLOCK_MONOTONIC);
sub unpack_ipv6 ($) {
my ($addr) = @_;
+ my ($port, $host);
- # TODO: support IO::Socket::IP which comes with Perl 5.24
- # (perl-modules-5.24 in Debian)
+ # Socket.pm in Perl 5.14+ supports IPv6:
+ eval {
+ ($port, $host) = Socket::unpack_sockaddr_in6($addr);
+ $host = Socket::inet_ntop(Socket::AF_INET6(), $host);
+ };
- # SpamAssassin and Net::Server use Socket6, so it may be installed
- # on our system, already:
- eval { require Socket6 } or return ('???-Socket6-missing', 0);
+ if ($@) {
+ # Perl 5.12 or earlier? SpamAssassin and Net::Server use
+ # Socket6, so it may be installed on our system, already
+ # (otherwise die here):
+ require Socket6;
- my ($port, $host) = Socket6::unpack_sockaddr_in6($addr);
- $host = Socket6::inet_ntop(Socket6::AF_INET6(), $host);
+ ($port, $host) = Socket6::unpack_sockaddr_in6($addr);
+ $host = Socket6::inet_ntop(Socket6::AF_INET6(), $host);
+ }
($host, $port);
}
PublicInbox::Listener->new($_, $post_accept)
} @listeners;
PublicInbox::EvCleanup::enable();
- Danga::Socket->EventLoop;
+ PublicInbox::DS->EventLoop;
$parent_pipe = undef;
}