[newlib-cygwin] Always try to write complete incoming buffer on pipes and fifos
Corinna Vinschen
corinna@sourceware.org
Sat Jan 14 15:29:00 GMT 2017
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=688d943a520cf79b04e67d890cdeeefaf90d269c
commit 688d943a520cf79b04e67d890cdeeefaf90d269c
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sat Jan 14 16:29:06 2017 +0100
Always try to write complete incoming buffer on pipes and fifos
This patch fixes the following problem:
Commit 9636c426 refactored the pipe code especially to make sure
to call WriteFile only with chunks matching the maximum atomic write
count. This accidentally introduced a small change in behaviour
on blocking pipes due to the success case falling through into the
error case. Rather then writing atomic chunks until all bytes are
written, the code immediately broke from the loop after writing
the first chunk, basically the same as in case of non-blocking
writes. This behaviour is not compliant to POSIX which requires
"Write requests to a pipe or FIFO [...]
* If the O_NONBLOCK flag is clear, a write request may cause the
thread to block, but on normal completion it shall return nbyte."
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 9ab52ad..a8fe3b6 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -2155,7 +2155,7 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
case overlapped_success:
ptr = ((char *) ptr) + chunk;
nbytes += nbytes_now;
- /* fall through intentionally */
+ break;
case overlapped_error:
len = 0; /* terminate loop */
case overlapped_unknown:
More information about the Cygwin-cvs
mailing list