diff options
| author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2006-03-01 07:03:13 +0000 |
|---|---|---|
| committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2006-03-01 07:03:13 +0000 |
| commit | 2d222de34b69aa69619af238be8a4c31088085a9 (patch) | |
| tree | fa645453e79cf0b78d730dc2f21eab30dee27587 | |
| parent | 6800857f5185a374bfb731c85d390a744c4e483c (diff) | |
| download | libapr-2d222de34b69aa69619af238be8a4c31088085a9.tar.gz | |
This patch needs additional pairs of eyeballs before considering
for backport. We bucket the bytecount results from ReadFile and
GetOverlappedResult into a true DWORD buffer, and then pass that
value across to the apr_size_t *nbytes argument, which on Win64
is a quadword. Please vote for correctness.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@381936 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | file_io/win32/readwrite.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c index 3faf7e0ed..66a4580b5 100644 --- a/file_io/win32/readwrite.c +++ b/file_io/win32/readwrite.c @@ -32,7 +32,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le { apr_status_t rv; DWORD len = (DWORD)len_in; - *nbytes = 0; + DWORD bytesread = 0; /* Handle the zero timeout non-blocking case */ if (file->timeout == 0) { @@ -46,10 +46,12 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le if (rv == APR_FROM_OS_ERROR(ERROR_BROKEN_PIPE)) { rv = APR_EOF; } + *nbytes = 0; return rv; } else { if (bytes == 0) { + *nbytes = 0; return APR_EAGAIN; } if (len > bytes) { @@ -70,8 +72,9 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le file->pOverlapped->OffsetHigh = (DWORD)(file->filePtr >> 32); } - *nbytes = 0; - rv = ReadFile(file->filehand, buf, len, nbytes, file->pOverlapped); + rv = ReadFile(file->filehand, buf, len, + &bytesread, file->pOverlapped); + *nbytes = bytesread; if (!rv) { rv = apr_get_os_error(); @@ -88,7 +91,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le switch (rv) { case WAIT_OBJECT_0: GetOverlappedResult(file->filehand, file->pOverlapped, - nbytes, TRUE); + &bytesread, TRUE); rv = APR_SUCCESS; break; @@ -332,7 +335,9 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a rv = WaitForSingleObject(thefile->pOverlapped->hEvent, timeout_ms); switch (rv) { case WAIT_OBJECT_0: - GetOverlappedResult(thefile->filehand, thefile->pOverlapped, nbytes, TRUE); + GetOverlappedResult(thefile->filehand, thefile->pOverlapped, + &bwrote, TRUE); + *nbytes = bwrote; rv = APR_SUCCESS; break; case WAIT_TIMEOUT: |
