diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-09-27 16:52:00 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-09-27 16:52:00 -0400 |
commit | e79ad711a0108475c1b3a03815527e7237020b08 (patch) | |
tree | 77551ee6c67b5901d7c66ff9daf2a8c6df9b0d41 /net/socket.c | |
parent | ff0ce6845bc18292e80ea40d11c3d3a539a3fc5e (diff) |
[NET]: Zero length write() on socket should not simply return 0.
This fixes kernel bugzilla #5731
It should generate an empty packet for datagram protocols when the
socket is connected, for one.
The check is doubly-wrong because all that a write() can be is a
sendmsg() call with a NULL msg_control and a single entry iovec. No
special semantics should be assigned to it, therefore the zero length
check should be removed entirely.
This matches the behavior of BSD and several other systems.
Alan Cox notes that SuSv3 says the behavior of a zero length write on
non-files is "unspecified", but that's kind of useless since BSD has
defined this behavior for a quarter century and BSD is essentially
what application folks code to.
Based upon a patch from Stephen Hemminger.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/net/socket.c b/net/socket.c index 7d44453dfae1..b09eb9036a17 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -777,9 +777,6 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
777 | if (pos != 0) | 777 | if (pos != 0) |
778 | return -ESPIPE; | 778 | return -ESPIPE; |
779 | 779 | ||
780 | if (iocb->ki_left == 0) /* Match SYS5 behaviour */ | ||
781 | return 0; | ||
782 | |||
783 | x = alloc_sock_iocb(iocb, &siocb); | 780 | x = alloc_sock_iocb(iocb, &siocb); |
784 | if (!x) | 781 | if (!x) |
785 | return -ENOMEM; | 782 | return -ENOMEM; |