about summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-03-15 14:33:27 +0000
committerRoland McGrath <roland@gnu.org>1999-03-15 14:33:27 +0000
commitd012636f1f27cfd477aa87faabca089387655b25 (patch)
treeacb78bf11b06b1f1a1a29050b919213f439cfc3f /sysdeps/mach
parent9cfba5dc11db58e94c1ef828aa9274b58bdfc513 (diff)
downloadglibc-d012636f1f27cfd477aa87faabca089387655b25.tar.gz
glibc-d012636f1f27cfd477aa87faabca089387655b25.tar.xz
glibc-d012636f1f27cfd477aa87faabca089387655b25.zip
1999-03-15 Mark Kettenis <kettenis@gnu.org>
	* sysdeps/mach/hurd/poll.c (__poll): Correctly pass NULL to
	_hurd_select if TIMEMOUT is -1.

1999-03-15  Mark Kettenis  <kettenis@gnu.org>

	* sysdeps/mach/hurd/recvfrom.c (recvfrom): Allow ADDR to be NULL.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/recvfrom.c69
1 files changed, 38 insertions, 31 deletions
diff --git a/sysdeps/mach/hurd/recvfrom.c b/sysdeps/mach/hurd/recvfrom.c
index ab41612d71..b39528628c 100644
--- a/sysdeps/mach/hurd/recvfrom.c
+++ b/sysdeps/mach/hurd/recvfrom.c
@@ -23,9 +23,10 @@
 #include <hurd/fd.h>
 #include <hurd/socket.h>
 
-/* Read N bytes into BUF through socket FD from peer
-   at address ADDR (which is ADDR_LEN bytes long).
-   Returns the number read or -1 for errors.  */
+/* Read N bytes into BUF through socket FD.
+   If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
+   the sender, and store the actual size of the address in *ADDR_LEN.
+   Returns the number of bytes read or -1 for errors.  */
 int
 recvfrom (fd, buf, n, flags, addrarg, addr_len)
      int fd;
@@ -53,37 +54,43 @@ recvfrom (fd, buf, n, flags, addrarg, addr_len)
 					       n)))
     return __hurd_dfail (fd, err);
 
-  /* Get address data for the returned address port.  */
-  {
-    char *buf = (char *) addr;
-    mach_msg_type_number_t buflen = *addr_len;
-    int type;
+  /* Get address data for the returned address port if requested.  */
+  if (addr != NULL)
+    {
+      char *buf = (char *) addr;
+      mach_msg_type_number_t buflen = *addr_len;
+      int type;
+
+      err = __socket_whatis_address (addrport, &type, &buf, &buflen);
+      if (err == EOPNOTSUPP)
+	/* If the protocol server can't tell us the address, just return a
+	   zero-length one.  */
+	{
+	  buf = (char *)addr;
+	  buflen = 0;
+	  err = 0;
+	}
 
-    err = __socket_whatis_address (addrport, &type, &buf, &buflen);
-    if (err == EOPNOTSUPP)
-      /* If the protocol server can't tell us the address, just return a
-	 zero-length one.  */
-      {
-	buf = (char *)addr;
-	buflen = 0;
-	err = 0;
-      }
-    __mach_port_deallocate (__mach_task_self (), addrport);
-    if (err)
-      return __hurd_dfail (fd, err);
+      if (err)
+	{
+	  __mach_port_deallocate (__mach_task_self (), addrport);
+	  return __hurd_dfail (fd, err);
+	}
+      
+      if (*addr_len > buflen)
+	*addr_len = buflen;
 
-    if (*addr_len > buflen)
-      *addr_len = buflen;
-    
-    if (buf != (char *) addr)
-      {
-	memcpy (addr, buf, *addr_len);
-	__vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
-      }
+      if (buf != (char *) addr)
+	{
+	  memcpy (addr, buf, *addr_len);
+	  __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+	}
+
+      if (buflen > 0)
+	addr->sa_family = type;
+    }
 
-    if (buflen > 0)
-      addr->sa_family = type;
-  }
+  __mach_port_deallocate (__mach_task_self (), addrport);
 
   /* Toss control data; we don't care.  */
   __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen);