diff options
author | Eric Wong <e@80x24.org> | 2016-03-11 21:59:42 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-03-11 22:03:21 +0000 |
commit | d5fce291ff67459ccf2939afea0ea6a1157869d8 (patch) | |
tree | 242dda59e01aa46e0814ac6750df4239d2a618ea /lib/PublicInbox/Daemon.pm | |
parent | ea1b6cbd422b7e392cdb6979837a42679b0f180f (diff) | |
download | public-inbox-d5fce291ff67459ccf2939afea0ea6a1157869d8.tar.gz |
We need to ensure $sock_pkg is preserved outside of the loop. The variable passed to "for" or "foreach" is implicitly local and restores the previous value when the loop exits. This is documented in the perlsyn manpage in the "Foreach Loops" section. Fixes: ea1b6cbd422b ("daemon: allow using IO::Socket::IP over INET6")
Diffstat (limited to 'lib/PublicInbox/Daemon.pm')
-rw-r--r-- | lib/PublicInbox/Daemon.pm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index fcb1a3d3..c6fb62bf 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -69,7 +69,8 @@ sub daemon_prepare ($) { $o{Local} = delete $o{Peer}; } else { # both work for IPv4, too - for $sock_pkg (qw(IO::Socket::IP IO::Socket::INET6)) { + for (qw(IO::Socket::IP IO::Socket::INET6)) { + $sock_pkg = $_; eval "use $sock_pkg"; $@ or last; } @@ -79,7 +80,7 @@ sub daemon_prepare ($) { $o{Listen} = 1024; my $prev = umask 0000; my $s = eval { $sock_pkg->new(%o) }; - warn "error binding $l: $!\n" unless $s; + warn "error binding $l: $! ($@)\n" unless $s; umask $prev; if ($s) { |