Only in Cache-Memcached-1.14: blib Only in Cache-Memcached-1.14: Makefile diff -ur Cache-Memcached-1.14-orig/Memcached.pm Cache-Memcached-1.14/Memcached.pm --- Cache-Memcached-1.14-orig/Memcached.pm 2004-07-27 12:07:04.000000000 -0500 +++ Cache-Memcached-1.14/Memcached.pm 2006-07-26 12:27:50.000000000 -0500 @@ -10,7 +10,7 @@ use strict; no strict 'refs'; use Storable (); -use Socket qw( MSG_NOSIGNAL PF_INET IPPROTO_TCP SOCK_STREAM ); +use Socket qw( MSG_NOSIGNAL PF_INET PF_UNIX IPPROTO_TCP SOCK_STREAM ); use IO::Handle (); use Time::HiRes (); use String::CRC32; @@ -209,22 +209,31 @@ my $sin; my $proto = $PROTO_TCP ||= getprotobyname('tcp'); - # if a preferred IP is known, try that first. - if ($self && $self->{pref_ip}{$ip}) { - socket($sock, PF_INET, SOCK_STREAM, $proto); - my $prefip = $self->{pref_ip}{$ip}; - $sin = Socket::sockaddr_in($port,Socket::inet_aton($prefip)); - if (_connect_sock($sock,$sin,0.1)) { - $connected = 1; - } else { - close $sock; + # check if unix or inet socket and handle accordingly + if ( $host !~ m{^/} ) { + # if a preferred IP is known, try that first. + if ($self && $self->{pref_ip}{$ip}) { + socket($sock, PF_INET, SOCK_STREAM, $proto); + my $prefip = $self->{pref_ip}{$ip}; + $sin = Socket::sockaddr_in($port,Socket::inet_aton($prefip)); + if (_connect_sock($sock,$sin,0.1)) { + $connected = 1; + } else { + close $sock; + } } - } - # normal path, or fallback path if preferred IP failed - unless ($connected) { - socket($sock, PF_INET, SOCK_STREAM, $proto); - $sin = Socket::sockaddr_in($port,Socket::inet_aton($ip)); + # normal path, or fallback path if preferred IP failed + unless ($connected) { + socket($sock, PF_INET, SOCK_STREAM, $proto); + $sin = Socket::sockaddr_in($port,Socket::inet_aton($ip)); + unless (_connect_sock($sock,$sin)) { + return _dead_sock($sock, undef, 20 + int(rand(10))); + } + } + } else { # it's a unix domain/local socket + socket($sock, PF_UNIX, SOCK_STREAM, 0); + $sin = Socket::sockaddr_un($host); unless (_connect_sock($sock,$sin)) { return _dead_sock($sock, undef, 20 + int(rand(10))); } @@ -900,7 +909,7 @@ use Cache::Memcached; $memd = new Cache::Memcached { - 'servers' => [ "10.0.0.15:11211", "10.0.0.15:11212", + 'servers' => [ "10.0.0.15:11211", "10.0.0.15:11212", "/var/sock/memcached", "10.0.0.17:11211", [ "10.0.0.17:11211", 3 ] ], 'debug' => 0, 'compress_threshold' => 10_000, Only in Cache-Memcached-1.14: pm_to_blib