diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2007-02-16 19:13:58 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2007-02-16 19:13:58 +0000 |
commit | acb9daec7453d5583e4de991be0b7b730305b867 (patch) | |
tree | d873d276d83fcf1b0f9539d6edad151159999a4b /gnu/usr.bin/perl | |
parent | 40f93bc90d349db8c305b49b5be446d1508365cb (diff) |
Back-port a getpeername() fix from IO version 1.30.
Also add a missing defined() that fixes send on unix domain sockets.
Diffstat (limited to 'gnu/usr.bin/perl')
-rw-r--r-- | gnu/usr.bin/perl/ext/IO/lib/IO/Socket.pm | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gnu/usr.bin/perl/ext/IO/lib/IO/Socket.pm b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket.pm index 4429f2bb3e6..57ef71a8a18 100644 --- a/gnu/usr.bin/perl/ext/IO/lib/IO/Socket.pm +++ b/gnu/usr.bin/perl/ext/IO/lib/IO/Socket.pm @@ -195,9 +195,7 @@ sub sockname { sub peername { @_ == 1 or croak 'usage: $sock->peername()'; my($sock) = @_; - getpeername($sock) - || ${*$sock}{'io_socket_peername'} - || undef; + ${*$sock}{'io_socket_peername'} ||= getpeername($sock); } sub connected { @@ -213,7 +211,7 @@ sub send { my $peer = $_[3] || $sock->peername; croak 'send: Cannot determine peer address' - unless($peer); + unless(defined($peer)); my $r = defined(getpeername($sock)) ? send($sock, $_[1], $flags) @@ -239,6 +237,7 @@ sub recv { sub shutdown { @_ == 2 or croak 'usage: $sock->shutdown(HOW)'; my($sock, $how) = @_; + ${*$sock}{'io_socket_peername'} = undef; shutdown($sock, $how); } |