[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#833557: hurd: PF_LOCAL send/recv don't honor MSG_DONTWAIT



Package: hurd
Version: 1:0.8.git20160522-4
Severity: normal
Tags: patch upstream

Dear Maintainer,

send/sendto/sendmsg/recv/recvfrom/recvmsg in combination with PF_LOCAL
sockets don't honor MSG_DONTWAIT. If specified, the operation will
block anyway. This is really bad if one has code that relies on the
fact that a recv* returns EAGAIN once all data has been read.

I've reported this to the debian-hurd and bug-hurd mailing lists, and
also provided a reproducer for this issue:
https://lists.gnu.org/archive/html/bug-hurd/2016-08/msg00000.html
https://lists.debian.org/debian-hurd/2016/08/msg00000.html

I've investigated further and found the culprit in hurd's
pflocal/socket.c. I've attached a patch that fixes the issue for me.
I've also sent the patch to both mailing lists:
https://lists.gnu.org/archive/html/bug-hurd/2016-08/msg00011.html
https://lists.debian.org/debian-hurd/2016/08/msg00008.html

Regards,
Christian

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)

Kernel: GNU-Mach 1.7+git20160607-486/Hurd-0.8
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to C.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages hurd depends on:
ii  hurd-libs0.3  1:0.8.git20160522-4+b1
ii  libblkid1     2.28-6
ii  libbz2-1.0    1.0.6-8
ii  libc0.3       2.23-4
ii  libdaemon0    0.14-6
ii  libncursesw5  6.0+20160625-1+b1
ii  libtinfo5     6.0+20160625-1+b1
ii  libx11-6      2:1.6.3-1
ii  netdde        0.0.20150828-3
ii  sysv-rc       2.88dsf-59.8
ii  xkb-data      2.17-1
ii  zlib1g        1:1.2.8.dfsg-2

Versions of packages hurd recommends:
ii  bf-utf-source  0.07

Versions of packages hurd suggests:
pn  hurd-doc  <none>

-- Configuration Files:
/etc/default/hurd-console changed [not included]

-- no debconf information
Description: Support MSG_DONTWAIT in pflocal send/recv
Author: Christian Seiler <christian@iwakd.de>
Bug: https://lists.gnu.org/archive/html/bug-hurd/2016-08/msg00000.html
Last-Update: 2016-08-05
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/pflocal/socket.c
+++ b/pflocal/socket.c
@@ -282,6 +282,7 @@ S_socket_send (struct sock_user *user, s
 	       size_t *amount)
 {
   error_t err = 0;
+  int noblock;
   struct pipe *pipe;
   struct sock *sock, *dest_sock;
   struct addr *source_addr;
@@ -333,8 +334,9 @@ S_socket_send (struct sock_user *user, s
 	
       if (!err)
 	{
-	  err = pipe_send (pipe, sock->flags & PFLOCAL_SOCK_NONBLOCK,
-			   source_addr, data, data_len,
+	  noblock = (user->sock->flags & PFLOCAL_SOCK_NONBLOCK)
+		    || (flags & MSG_DONTWAIT);
+	  err = pipe_send (pipe, noblock, source_addr, data, data_len,
 			   control, control_len, ports, num_ports,
 			   amount);
 	  if (dest_sock)
@@ -373,6 +375,7 @@ S_socket_recv (struct sock_user *user,
 {
   error_t err;
   unsigned flags;
+  int noblock;
   struct pipe *pipe;
   void *source_addr = NULL;
 
@@ -398,10 +401,11 @@ S_socket_recv (struct sock_user *user,
     }
   else if (!err)
     {
+      noblock = (user->sock->flags & PFLOCAL_SOCK_NONBLOCK)
+		|| (in_flags & MSG_DONTWAIT);
       err =
-	pipe_recv (pipe, user->sock->flags & PFLOCAL_SOCK_NONBLOCK, &flags,
-		   &source_addr, data, data_len, amount,
-		   control, control_len, ports, num_ports);
+	pipe_recv (pipe, noblock, &flags, &source_addr, data, data_len,
+		   amount, control, control_len, ports, num_ports);
       pipe_release_reader (pipe);
     }
 

Reply to: