mirror of https://github.com/getdnsapi/getdns.git
Merge pull request #276 from huitema/develop
Fixing the select and poll event loops for Windows
This commit is contained in:
commit
148dfabf88
|
@ -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,9 +36,13 @@
|
|||
# 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"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/conf.h>
|
||||
|
|
Loading…
Reference in New Issue