user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] daemon: fixup usage of the '-l' switch with IP/INET6 sockets
@ 2016-03-11 22:05  5% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-03-11 22:05 UTC (permalink / raw)
  To: meta

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")
---
 lib/PublicInbox/Daemon.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index fcb1a3d..c6fb62b 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) {
-- 
EW


^ permalink raw reply related	[relevance 5%]

* [PATCH] daemon: allow using IO::Socket::IP over INET6
@ 2016-03-07 17:43  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-03-07 17:43 UTC (permalink / raw)
  To: meta

IO::Socket::IP is bundled with newer versions of Perl,
so it is more likely to be available.  There should
be no differences between these with our use cases.
---
 lib/PublicInbox/Daemon.pm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index a6707e8..fcb1a3d 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -68,8 +68,11 @@ sub daemon_prepare ($) {
 			}
 			$o{Local} = delete $o{Peer};
 		} else {
-			$sock_pkg = 'IO::Socket::INET6'; # works for IPv4, too
-			eval "use $sock_pkg";
+			# both work for IPv4, too
+			for $sock_pkg (qw(IO::Socket::IP IO::Socket::INET6)) {
+				eval "use $sock_pkg";
+				$@ or last;
+			}
 			die $@ if $@;
 			%o = (LocalAddr => $l, ReuseAddr => 1, Proto => 'tcp');
 		}
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-03-07 17:43  7% [PATCH] daemon: allow using IO::Socket::IP over INET6 Eric Wong
2016-03-11 22:05  5% [PATCH] daemon: fixup usage of the '-l' switch with IP/INET6 sockets Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).