[PATCH] Fix return value on aio_read/write success

Mark Geisert mark@maxrnd.com
Sat Aug 4 08:44:00 GMT 2018


Oops. Something that iozone testing had found but I regarded as an
iozone bug.  Re-reading the man pages set me straight.
---
 winsup/cygwin/aio.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/aio.cc b/winsup/cygwin/aio.cc
index fe63dec04..571a9621b 100644
--- a/winsup/cygwin/aio.cc
+++ b/winsup/cygwin/aio.cc
@@ -712,7 +712,7 @@ aio_read (struct aiocb *aio)
       ; /* I think this is not possible */
     }
 
-  return res;
+  return res < 0 ? res : 0; /* Return 0 on success, not byte count */
 }
 
 ssize_t
@@ -902,7 +902,7 @@ aio_write (struct aiocb *aio)
       ; /* I think this is not possible */
     }
 
-  return res;
+  return res < 0 ? res : 0; /* Return 0 on success, not byte count */
 }
 
 int
-- 
2.17.0



More information about the Cygwin-patches mailing list