summaryrefslogtreecommitdiff
path: root/file_io
diff options
context:
space:
mode:
authorIvan Zhakov <ivan@apache.org>2019-05-27 06:56:50 +0000
committerIvan Zhakov <ivan@apache.org>2019-05-27 06:56:50 +0000
commite16518fd86880295929f10bc79c9f57d2dbe524f (patch)
treeeb6935a115fbc761800553a89b235fceac6cb990 /file_io
parentf0ec3634d7c1abad8cdb4da62b5a06821514e2af (diff)
downloadapr-e16518fd86880295929f10bc79c9f57d2dbe524f.tar.gz
* file_io/win32/readwrite.c
(read_with_timeout, apr_file_write): Use apr_wait_for_single_object() helper. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r--file_io/win32/readwrite.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c
index bf7cbfb30..9c06ded63 100644
--- a/file_io/win32/readwrite.c
+++ b/file_io/win32/readwrite.c
@@ -87,11 +87,8 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le
* one owner to a new proc/thread.
*/
do {
- res = WaitForSingleObject(file->pOverlapped->hEvent,
- (file->timeout > 0)
- ? (DWORD)(file->timeout/1000)
- : ((file->timeout == -1)
- ? INFINITE : 0));
+ res = apr_wait_for_single_object(file->pOverlapped->hEvent,
+ file->timeout);
} while (res == WAIT_ABANDONED);
/* There is one case that represents entirely
@@ -492,20 +489,10 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a
if (rv == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) {
- DWORD timeout_ms;
DWORD res;
- if (thefile->timeout == 0) {
- timeout_ms = 0;
- }
- else if (thefile->timeout < 0) {
- timeout_ms = INFINITE;
- }
- else {
- timeout_ms = (DWORD)(thefile->timeout / 1000);
- }
-
- res = WaitForSingleObject(thefile->pOverlapped->hEvent, timeout_ms);
+ res = apr_wait_for_single_object(thefile->pOverlapped->hEvent,
+ thefile->timeout);
/* There is one case that represents entirely
* successful operations, otherwise we will cancel
@@ -533,7 +520,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a
&& (res == WAIT_TIMEOUT))
rv = APR_TIMEUP;
- if (rv == APR_TIMEUP && timeout_ms == 0) {
+ if (rv == APR_TIMEUP && thefile->timeout == 0) {
rv = APR_EAGAIN;
}
}