win32: make g_cond_wait_until() wait at least until end_time before returning…
win32: make g_cond_wait_until() wait at least until end_time before returning with a timeout. See #1371
The tests in test_async_queue_timed() assume that g_async_queue_timeout_pop() and in turn g_cond_wait_until() wait at least until end_time before returning, i.e. calling g_get_monotonic_time() after the timeout should result in a value equal or larger than the timeout end time.
For the win32 implementation of g_cond_wait_until() this isn't the case which makes those tests fail.
There are three reasons why the function returns early:
- The underlying API works with milliseconds and the timeout gets rounded down, resulting in a too small timeout value.
- In case the timeout is too large to be passed to the API it gets limited (there is also a bug because it converts INFINITE to milliseconds while they already are, but using INFINITE would be wrong as well, as passing a large timeout is not the same as blocking forever really)
- Even with the rounding changed the underlying API still returns a bit early sometimes on my machine (relative to g_get_monotonic_time())
This changes the implementation to round up to the next millisecond (fixing 1) and to wait again in case a timeout occurs but the end time hasn't been reached yet (fixing 2 and 3).
This makes the test_async_queue_timed() tests pass.