2008-07-01 Samuel Thibault <samuel.thibault@ens-lyon.org>
authorRoland McGrath <roland@gnu.org>
Wed, 2 Jul 2008 09:53:29 +0000 (09:53 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 2 Jul 2008 09:53:29 +0000 (09:53 +0000)
* sysdeps/unix/bsd/bsd4.4/bits/socket.h: Define MSG_NOSIGNAL.
* hurd/hurd/fd.h (__hurd_sockfail): Add extern inline function.
* sysdeps/mach/hurd/recv.c (__recv): Use __hurd_sockfail instead of
__hurd_dfail.
* sysdeps/mach/hurd/recvfrom.c (__recvfrom): Likewise
* sysdeps/mach/hurd/recvmsg.c (__recvmsg): Likewise
* sysdeps/mach/hurd/send.c (__send): Likewise
* sysdeps/mach/hurd/sendfrom.c (__sendfrom): Likewise
* sysdeps/mach/hurd/sendmsg.c (__sendmsg): Likewise

hurd/hurd/fd.h
sysdeps/mach/hurd/recv.c
sysdeps/mach/hurd/recvfrom.c
sysdeps/mach/hurd/recvmsg.c
sysdeps/mach/hurd/send.c
sysdeps/mach/hurd/sendmsg.c
sysdeps/unix/bsd/bsd4.4/bits/socket.h

index 08d4407..d1aa867 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <hurd/hurd_types.h>
 #include <hurd/port.h>
+#include <sys/socket.h>
 
 
 /* Structure representing a file descriptor.  */
@@ -179,6 +180,18 @@ __hurd_dfail (int fd, error_t err)
   errno = _hurd_fd_error (fd, err);
   return -1;
 }
+
+/* Likewise, but do not raise SIGPIPE on EPIPE if flags contain
+   MSG_NOSIGNAL.  */
+
+_HURD_FD_H_EXTERN_INLINE int
+__hurd_sockfail (int fd, int flags, error_t err)
+{
+  if (!(flags & MSG_NOSIGNAL) || err != EPIPE)
+    err = _hurd_fd_error (fd, err);
+  errno = err;
+  return -1;
+}
 \f
 /* Set up *FD to have PORT its server port, doing appropriate ctty magic.
    Does no locking or unlocking.  */
index b001729..a01e609 100644 (file)
@@ -48,7 +48,7 @@ __recv (fd, buf, n, flags)
                                               &cdata, &clen,
                                               &flags,
                                               n)))
-    return __hurd_dfail (fd, err);
+    return __hurd_sockfail (fd, flags, err);
 
   __mach_port_deallocate (__mach_task_self (), addrport);
   __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen);
index d5c73f4..d30bc40 100644 (file)
@@ -52,7 +52,7 @@ __recvfrom (fd, buf, n, flags, addrarg, addr_len)
                                               &cdata, &clen,
                                               &flags,
                                               n)))
-    return __hurd_dfail (fd, err);
+    return __hurd_sockfail (fd, flags, err);
 
   /* Get address data for the returned address port if requested.  */
   if (addr != NULL)
@@ -74,7 +74,7 @@ __recvfrom (fd, buf, n, flags, addrarg, addr_len)
       if (err)
        {
          __mach_port_deallocate (__mach_task_self (), addrport);
-         return __hurd_dfail (fd, err);
+         return __hurd_sockfail (fd, flags, err);
        }
       
       if (*addr_len > buflen)
index c6874e8..15f9fb1 100644 (file)
@@ -63,7 +63,7 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags)
                                               &ports, &nports,
                                               &cdata, &clen,
                                               &message->msg_flags, amount)))
-    return __hurd_dfail (fd, err);
+    return __hurd_sockfail (fd, flags, err);
 
   if (message->msg_name != NULL)
     {
@@ -84,7 +84,7 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags)
       if (err)
        {
          __mach_port_deallocate (__mach_task_self (), aport);
-         return __hurd_dfail (fd, err);
+         return __hurd_sockfail (fd, flags, err);
        }
 
       if (message->msg_namelen > buflen)
index 4810cd6..bb45c50 100644 (file)
@@ -38,7 +38,7 @@ __send (fd, buf, n, flags)
                                           NULL, MACH_MSG_TYPE_COPY_SEND, 0,
                                           NULL, 0, &wrote));
 
-  return err ? __hurd_dfail (fd, err) : wrote;
+  return err ? __hurd_sockfail (fd, flags, err) : wrote;
 }
 libc_hidden_def (__send)
 weak_alias (__send, send)
index 5fdfd73..a9d1c8c 100644 (file)
@@ -149,7 +149,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
   if (dealloc)
     __vm_deallocate (__mach_task_self (), data.addr, len);
 
-  return err ? __hurd_dfail (fd, err) : amount;
+  return err ? __hurd_sockfail (fd, flags, err) : amount;
 }
 
 weak_alias (__libc_sendmsg, sendmsg)
index 67db4d8..2ccd01d 100644 (file)
@@ -171,8 +171,10 @@ enum
 #define MSG_CTRUNC MSG_CTRUNC
     MSG_WAITALL                = 0x40, /* Wait for full request or error.  */
 #define MSG_WAITALL MSG_WAITALL
-    MSG_DONTWAIT       = 0x80  /* This message should be nonblocking.  */
+    MSG_DONTWAIT       = 0x80, /* This message should be nonblocking.  */
 #define MSG_DONTWAIT MSG_DONTWAIT
+    MSG_NOSIGNAL       = 0x0400        /* Do not generate SIGPIPE on EPIPE.  */
+#define MSG_NOSIGNAL MSG_NOSIGNAL
   };