Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only set EAGAIN when written == 0 and length > 0. Fixes #2957
Because we use NIO channels for all IO, but need to behave like POSIX IO functions, we emulate errno behavior for various cases. This particular issue is an edge case, when writing zero bytes to a stream marked as nonblocking (as happens after it is used in an IO.select operation); we see that it's nonblocking and nothing was written and unconditionally treat that as EAGAIN. Instead, we should only set EAGAIN when zero bytes are written and we actually did have bytes to write.