Thu 07 Jul 2016 07:50:18 PM UTC, comment #5:
I patched libpipe/pipe.c (pipe_recv) as described in comment #4, and the perl test case in the original submission no longer hangs. Neither does a similar test with /hurd/new-fifo.
I also ran the test suite of vim-7.4.1829 with this patch and a few others, and it passed.
Is there a test case for the pflocal problem mentioned in comment #2?
|
Wed 06 Jul 2016 04:04:24 PM UTC, comment #4:
IEEE Std 1003.1, 2013 Edition makes nbyte==0 a special case in the read and pread functions, but I don't see similar special cases in the recv, recvfrom, and recvmsg functions. AFAICT, those should consume the message from a message-based socket even if the buffer has zero length, unless MSG_PEEK is specified.
pflocal/io.c (S_io_read) calls pipe_read, which calls pipe_recv (pipe, noblock, 0, source, data, data_len, amount, 0,0,0,0).
pflocal/socket.c (S_socket_recv) calls pipe_recv (..., control, control_len, ports, num_ports). In hurd/socket.defs (socket_recv), those correspond to output parameters, so I believe they are not included in the request message and the mig-generated code will ensure that e.g. control != NULL.
I think pipe_read should then apply the shortcut behavior only if (amount == 0 && data_only). That way, the change would not affect recv, recvfrom, and recvmsg.
|
Fri 01 Jul 2016 10:00:01 PM UTC, original submission:
mkfifo da; sleep 1000 > da & rpctrace perl -e 'sysread STDIN, $_, 0' < da
hangs at: 136<--159(pid1132)->io_read (-1 0)
According to antrik, POSIX specifies that read with nbyte==0 must immediately return 0 or return an error. This could be implemented in libc, libtrivfs, fifo, or libpipe. It seems best to implement this in fifo or libpipe so that fifo can still return EBADF if the fifo was not opened for reading.
I filed this as distinct from bug 48371 (for the streamio translator) because they can be fixed and tested independently.
|