about summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2017-03-13 20:41:12 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2017-03-13 20:41:12 +0100
commit9d067269f5c3ecc5913e7e424a4778608d784731 (patch)
treec561c33582a593249173f8923be0c56d871c7c0c /sysdeps/mach
parentc89721e25d609ec4f3366a3956b2f3e5acd76e77 (diff)
downloadglibc-9d067269f5c3ecc5913e7e424a4778608d784731.tar.gz
glibc-9d067269f5c3ecc5913e7e424a4778608d784731.tar.xz
glibc-9d067269f5c3ecc5913e7e424a4778608d784731.zip
hurd: Make send/recv more posixish
Thanks David Michael for the suggestion.

	* sysdeps/mach/hurd/send.c (__send): Convert hurdish error code into
	posix error code.
	* sysdeps/mach/hurd/recv.c (__recv): Likewise.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/recv.c8
-rw-r--r--sysdeps/mach/hurd/send.c4
2 files changed, 10 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/recv.c b/sysdeps/mach/hurd/recv.c
index 78a67d0cd8..133f49dfaa 100644
--- a/sysdeps/mach/hurd/recv.c
+++ b/sysdeps/mach/hurd/recv.c
@@ -37,12 +37,16 @@ __recv (int fd, void *buf, size_t n, int flags)
   char *cdata = NULL;
   mach_msg_type_number_t clen = 0;
 
-  if (err = HURD_DPORT_USE (fd, __socket_recv (port, &addrport,
+  err = HURD_DPORT_USE (fd, __socket_recv (port, &addrport,
 					       flags, &bufp, &nread,
 					       &ports, &nports,
 					       &cdata, &clen,
 					       &flags,
-					       n)))
+					       n));
+  if (err == MIG_BAD_ID || err == EOPNOTSUPP)
+    /* The file did not grok the socket protocol.  */
+    err = ENOTSOCK;
+  if (err)
     return __hurd_sockfail (fd, flags, err);
 
   __mach_port_deallocate (__mach_task_self (), addrport);
diff --git a/sysdeps/mach/hurd/send.c b/sysdeps/mach/hurd/send.c
index 8eb97e99ee..98ffcbf562 100644
--- a/sysdeps/mach/hurd/send.c
+++ b/sysdeps/mach/hurd/send.c
@@ -33,6 +33,10 @@ __send (int fd, const void *buf, size_t n, int flags)
 					   NULL, MACH_MSG_TYPE_COPY_SEND, 0,
 					   NULL, 0, &wrote));
 
+  if (err == MIG_BAD_ID || err == EOPNOTSUPP)
+    /* The file did not grok the socket protocol.  */
+    err = ENOTSOCK;
+
   return err ? __hurd_sockfail (fd, flags, err) : wrote;
 }
 libc_hidden_def (__send)