From: Jarkko Hietaniemi Date: Sun, 9 Sep 2001 13:03:33 +0000 (+0000) Subject: Try to look up protocol (by name) only iff it has non-numbers: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7822251ecf4a18e47928777b0f052ad10c2a4a33;p=p5sagit%2Fp5-mst-13.2.git Try to look up protocol (by name) only iff it has non-numbers: nice if the server is in a chrooted environment (no /etc/protocols, server code using hardcorded protocol numbers like 6 for tcp), suggested by John Holdsworth . In other words, if we are given a number, why look it up again (by number)? p4raw-id: //depot/perl@11957 --- diff --git a/ext/IO/lib/IO/Socket/INET.pm b/ext/IO/lib/IO/Socket/INET.pm index b36a65b..8f1845b 100644 --- a/ext/IO/lib/IO/Socket/INET.pm +++ b/ext/IO/lib/IO/Socket/INET.pm @@ -41,11 +41,8 @@ sub _sock_info { $port = $1 if(defined $addr && $addr =~ s,:([\w\(\)/]+)$,,); - if(defined $proto) { - if (@proto = ( $proto =~ m,\D, - ? getprotobyname($proto) - : getprotobynumber($proto)) - ) { + if(defined $proto && $proto =~ /\D/) { + if(@proto = getprotobyname($proto) { $proto = $proto[2] || undef; } else {