You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2006/03/23 22:49:50 UTC
svn commit: r388281 - /apr/apr/trunk/file_io/win32/readwrite.c
Author: wrowe
Date: Thu Mar 23 13:49:49 2006
New Revision: 388281
URL: http://svn.apache.org/viewcvs?rev=388281&view=rev
Log:
Part 1 of many read_with_timeout logic fixes. Stop polluting one
occurance of rv with the boolean result of ReadFile() to increase
the legibility of the success/failure of ReadFile. This requires
us to defer *nbytes assignment to the function's end.
This fix catches additional cases of APR_EOF, as we had not
tested this case from the error handling path. So any deferred
read of zero bytes previously returned 0 bytes APR_SUCCESS
rather than APR_EOF. (This occurs when we wait to discover the
owner of the write end closes it without additional data)
Modified:
apr/apr/trunk/file_io/win32/readwrite.c
Modified: apr/apr/trunk/file_io/win32/readwrite.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/win32/readwrite.c?rev=388281&r1=388280&r2=388281&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/readwrite.c (original)
+++ apr/apr/trunk/file_io/win32/readwrite.c Thu Mar 23 13:49:49 2006
@@ -72,11 +72,11 @@
file->pOverlapped->OffsetHigh = (DWORD)(file->filePtr >> 32);
}
- rv = ReadFile(file->filehand, buf, len,
- &bytesread, file->pOverlapped);
- *nbytes = bytesread;
-
- if (!rv) {
+ if (ReadFile(file->filehand, buf, len,
+ &bytesread, file->pOverlapped)) {
+ rv = APR_SUCCESS;
+ }
+ else {
rv = apr_get_os_error();
if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) {
/* Wait for the pending i/o */
@@ -117,16 +117,16 @@
/* Assume ERROR_BROKEN_PIPE signals an EOF reading from a pipe */
rv = APR_EOF;
}
- } else {
- /* OK and 0 bytes read ==> end of file */
- if (*nbytes == 0)
- rv = APR_EOF;
- else
- rv = APR_SUCCESS;
+ }
+
+ /* OK and 0 bytes read ==> end of file */
+ if (rv == APR_SUCCESS && bytesread == 0)
+ rv = APR_EOF;
}
if (rv == APR_SUCCESS && file->pOverlapped && !file->pipe) {
- file->filePtr += *nbytes;
+ file->filePtr += bytesread;
}
+ *nbytes = bytesread;
return rv;
}