mirror of https://github.com/getdnsapi/getdns.git
Fixing the select event loop so it does not give up for naked timers in Windows.
Making sure the poll event loop works on windows. Fixing the poll event loop so it does not give up for naked timers in Windows.
This commit is contained in:
parent
0560500e34
commit
6f0b08a400
|
@ -30,8 +30,10 @@
|
|||
#ifdef HAVE_SYS_POLL_H
|
||||
#include <sys/poll.h>
|
||||
#else
|
||||
#ifndef USE_WINSOCK
|
||||
#include <poll.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
@ -402,6 +404,10 @@ poll_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
|||
, poll_timeout
|
||||
);
|
||||
#ifdef USE_WINSOCK
|
||||
if (poll_loop->fd_events_free == 0)
|
||||
{
|
||||
Sleep(poll_timeout);
|
||||
} else
|
||||
if (WSAPoll(poll_loop->pfds, poll_loop->fd_events_free, poll_timeout) < 0) {
|
||||
#else
|
||||
if (poll(poll_loop->pfds, poll_loop->fd_events_free, poll_timeout) < 0) {
|
||||
|
|
|
@ -234,6 +234,16 @@ select_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
|||
tv.tv_sec = (long)((timeout - now) / 1000000);
|
||||
tv.tv_usec = (long)((timeout - now) % 1000000);
|
||||
}
|
||||
#ifdef USE_WINSOCK
|
||||
if (max_fd == -1)
|
||||
{
|
||||
if (timeout != TIMEOUT_FOREVER)
|
||||
{
|
||||
uint32_t timeout_ms = (tv.tv_usec / 1000) + (tv.tv_sec * 1000);
|
||||
Sleep(timeout_ms);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (select(max_fd + 1, &readfds, &writefds, NULL,
|
||||
(timeout == TIMEOUT_FOREVER ? NULL : &tv)) < 0) {
|
||||
perror("select() failed");
|
||||
|
|
|
@ -36,7 +36,11 @@
|
|||
# ifdef HAVE_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
# else
|
||||
#ifdef USE_WINSOCK
|
||||
#define poll(fdarray, nbsockets, timer) WSAPoll(fdarray, nbsockets, timer)
|
||||
#else
|
||||
# include <poll.h>
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
#include "debug.h"
|
||||
|
|
Loading…
Reference in New Issue