diff options
author | ivan <ivan@13f79535-47bb-0310-9956-ffa450edef68> | 2019-05-27 17:11:23 +0000 |
---|---|---|
committer | ivan <ivan@13f79535-47bb-0310-9956-ffa450edef68> | 2019-05-27 17:11:23 +0000 |
commit | 5a0567d0470e8be395c0299306786a98992c6f25 (patch) | |
tree | c21f1deecd4de7b23398e40dddc6884bf5a2831f /misc/win32/misc.c | |
parent | a7a7248520a64aa924e24c44c9d75bf4bb2d893a (diff) | |
download | libapr-xmllite.tar.gz |
On 'xmllite' branch: Merge changes from trunk.xmllite
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/xmllite@1860149 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc/win32/misc.c')
-rw-r--r-- | misc/win32/misc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/misc/win32/misc.c b/misc/win32/misc.c index b6ee202b0..11b5b6b18 100644 --- a/misc/win32/misc.c +++ b/misc/win32/misc.c @@ -188,6 +188,36 @@ FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal) #endif } +DWORD apr_wait_for_single_object(HANDLE handle, apr_interval_time_t timeout) +{ + apr_interval_time_t t = timeout; + DWORD res; + DWORD timeout_ms = 0; + + do { + if (t < 0) { + timeout_ms = INFINITE; + } + else if (t > 0) { + /* Given timeout is 64bit usecs whereas Windows timeouts are + * 32bit msecs and below INFINITE (2^32 - 1), so we may need + * multiple timed out waits... + */ + if (t > apr_time_from_msec(INFINITE - 1)) { + timeout_ms = INFINITE - 1; + t -= apr_time_from_msec(INFINITE - 1); + } + else { + timeout_ms = (DWORD)apr_time_as_msec(t); + t = 0; + } + } + res = WaitForSingleObject(handle, timeout_ms); + } while (res == WAIT_TIMEOUT && t > 0); + + return res; +} + /* Declared in include/arch/win32/apr_dbg_win32_handles.h */ APR_DECLARE_NONSTD(HANDLE) apr_dbg_log(char* fn, HANDLE ha, char* fl, int ln, |