mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-23 11:49:50 +00:00
* Merged a bugfix from xdispatch within windows_kevent_wait causing wrong timeouts
git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@536 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
parent
f6a37c0a51
commit
d38e2e3479
@ -123,19 +123,25 @@ windows_kevent_wait(struct kqueue *kq, int no, const struct timespec *timeout)
|
||||
DWORD timeout_ms;
|
||||
BOOL success;
|
||||
|
||||
/* Convert timeout to milliseconds */
|
||||
/* NOTE: loss of precision for timeout values less than 1ms */
|
||||
if (timeout == NULL) {
|
||||
timeout_ms = INFINITE;
|
||||
} else {
|
||||
timeout_ms = 0;
|
||||
if (timeout->tv_sec > 0)
|
||||
timeout_ms += ((DWORD)timeout->tv_sec) / 1000;
|
||||
if (timeout->tv_sec > 0)
|
||||
timeout_ms += timeout->tv_nsec / 1000000;
|
||||
}
|
||||
if (timeout == NULL) {
|
||||
timeout_ms = INFINITE;
|
||||
} else if ( timeout->tv_sec == 0 && timeout->tv_nsec < 1000000 ) {
|
||||
/* do we need to try high precision timing? */
|
||||
// TODO: This is currently not possible on windows!
|
||||
timeout_ms = 0;
|
||||
} else { /* Convert timeout to milliseconds */
|
||||
timeout_ms = 0;
|
||||
if (timeout->tv_sec > 0)
|
||||
timeout_ms += ((DWORD)timeout->tv_sec) * 1000;
|
||||
if (timeout->tv_nsec > 0)
|
||||
timeout_ms += timeout->tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
dbg_printf("waiting for events (timeout=%u ms)", (unsigned int) timeout_ms);
|
||||
#if 0
|
||||
if(timeout_ms <= 0)
|
||||
dbg_printf("Woop, not waiting !?");
|
||||
#endif
|
||||
memset(&iocp_buf, 0, sizeof(iocp_buf));
|
||||
success = GetQueuedCompletionStatus(kq->kq_iocp,
|
||||
&iocp_buf.bytes, &iocp_buf.key, &iocp_buf.overlap,
|
||||
|
Loading…
Reference in New Issue
Block a user