You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2013/02/01 18:10:14 UTC

svn commit: r1441536 - /spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm

Author: mmartinec
Date: Fri Feb  1 17:10:13 2013
New Revision: 1441536

URL: http://svn.apache.org/viewvc?rev=1441536&view=rev
Log:
Bug 6547: let Client.pm use the same logic as DnsResolver.pm in deciding which of the IO modules to use (IO::Socket::IP preferred to older IO::Socket::INET6, which in turn is preferred to IPv4-only IO::Socket::INET)

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm?rev=1441536&r1=1441535&r2=1441536&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm Fri Feb  1 17:10:13 2013
@@ -60,20 +60,15 @@ use re 'taint';
 use IO::Socket;
 use Errno qw(EBADF);
 
-our($have_inet4, $have_inet6);
+our($io_socket_module_name);
 BEGIN {
-  $have_inet4 = eval {
-    require IO::Socket::INET;
-    my $sock = IO::Socket::INET->new(LocalAddr => '0.0.0.0', Proto => 'udp');
-    $sock->close or die "error closing inet socket: $!"  if $sock;
-    $sock ? 1 : undef;
-  };
-  $have_inet6 = eval {
-    require IO::Socket::INET6;
-    my $sock = IO::Socket::INET6->new(LocalAddr => '::', Proto => 'udp');
-    $sock->close or die "error closing inet6 socket: $!"  if $sock;
-    $sock ? 1 : undef;
-  };
+  if (eval { require IO::Socket::IP }) {
+    $io_socket_module_name = 'IO::Socket::IP';
+  } elsif (eval { require IO::Socket::INET6 }) {
+    $io_socket_module_name = 'IO::Socket::INET6';
+  } elsif (eval { require IO::Socket::INET }) {
+    $io_socket_module_name = 'IO::Socket::INET';
+  }
 }
 
 my $EOL = "\015\012";
@@ -469,13 +464,8 @@ sub _create_connection {
 		   PeerAddr => $self->{host},
 		   PeerPort => $self->{port},
 		   Timeout  => $self->{timeout},
-		  );
-    my $is_inet4 = $self->{host} =~ /^\d+\.\d+\.\d+\.\d+\z/;
-    if ($have_inet4 && ($is_inet4 || !$have_inet6)) {
-      $remote = IO::Socket::INET->new( %params );
-    } else {
-      $remote = IO::Socket::INET6->new( %params );
-    }
+		 );
+    $remote = $io_socket_module_name->new(%params);
   }
 
   unless ($remote) {