-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LibOS] Return
0
on zero-sized read()
syscalls on sockets
On Linux, `read(socket-fd, buf, /*count=*/0)` has a special case of returning zero, after all checks. Same applies for `readv()`. However, this does *not* apply to `recvfrom()`, `recvmsg()`, `recvmmsg()`. Linux code simply says "Match SYS5 behavior" in this corner case: https://github.com/torvalds/linux/blob/99bd3cb0d12e85/net/socket.c#L1136-L1136 Apparently some applications/libraries rely on this behavior. Without this corner case, these apps would hang (if the socket is blocking) or unexpectedly return -EAGAIN (if the socket is non-blocking). Note that the underlying PalSocketRecv() uses `recvmsg()` syscall, at least on Linux-based PALs, so a simple fall-through to PAL would change the semantics of `read()`/`readv()` issued by the app. Signed-off-by: Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
- Loading branch information
Showing
3 changed files
with
26 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters