socketpair tweaks from Nicholas Clark.
authorJarkko Hietaniemi <jhi@iki.fi>
Sat, 29 Dec 2001 15:05:08 +0000 (15:05 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 29 Dec 2001 15:05:08 +0000 (15:05 +0000)
p4raw-id: //depot/perl@13921

ext/Socket/socketpair.t
util.c

index c31e4df..653e1b7 100644 (file)
@@ -15,7 +15,7 @@ use Socket;
 use Test::More;
 use strict;
 use warnings;
-use Errno 'EPIPE';
+use Errno qw(EPIPE ESHUTDOWN);
 
 my $skip_reason;
 
@@ -89,7 +89,7 @@ $SIG{PIPE} = 'IGNORE';
 }
 SKIP: {
   # This may need skipping on some OSes
-  ok ($! == EPIPE, '$! should be EPIPE')
+  ok (($! == EPIPE or $! == ESHUTDOWN), '$! should be EPIPE or ESHUTDOWN')
     or printf "\$\!=%d(%s)\n", $!, $!;
 }
 
diff --git a/util.c b/util.c
index 6e50628..9607d46 100644 (file)
--- a/util.c
+++ b/util.c
@@ -4127,7 +4127,7 @@ S_socketpair_udp (int fd[2]) {
 int
 Perl_my_socketpair (int family, int type, int protocol, int fd[2]) {
     /* Stevens says that family must be AF_LOCAL, protocol 0.
-       I'm going to enforce that, then ignore it, and use TCP.  */
+       I'm going to enforce that, then ignore it, and use TCP (or UDP).  */
     int listener = -1;
     int connector = -1;
     int acceptor = -1;
@@ -4143,8 +4143,10 @@ Perl_my_socketpair (int family, int type, int protocol, int fd[2]) {
         errno = EAFNOSUPPORT;
         return -1;
     }
-    if (!fd)
-        return EINVAL;
+    if (!fd) {
+        errno = EINVAL;
+        return -1;
+    }
 
     if (type == SOCK_DGRAM)
         return S_socketpair_udp (fd);