Skip to content

Commit

Permalink
[NET]: Zero length write() on socket should not simply return 0.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Sep 27, 2007
1 parent ff0ce68 commit e79ad71
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,6 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (pos != 0)
return -ESPIPE;

if (iocb->ki_left == 0) /* Match SYS5 behaviour */
return 0;

x = alloc_sock_iocb(iocb, &siocb);
if (!x)
return -ENOMEM;
Expand Down

0 comments on commit e79ad71

Please sign in to comment.