From: William Horvath william@horvath.blog
This allows higher precision waits, to match the other platforms where we can already use a timespec directly.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57849 --- configure.ac | 1 + server/fd.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 20c2cceadee..18aa26e9e92 100644 --- a/configure.ac +++ b/configure.ac @@ -2062,6 +2062,7 @@ AC_CHECK_FUNCS(\ dladdr1 \ dlinfo \ epoll_create \ + epoll_pwait2 \ fstatfs \ futimens \ futimes \ diff --git a/server/fd.c b/server/fd.c index 9e28c1b9fcf..3fd7f459dc2 100644 --- a/server/fd.c +++ b/server/fd.c @@ -102,6 +102,9 @@ #if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_EPOLL_CREATE) # include <sys/epoll.h> # define USE_EPOLL +# ifdef HAVE_EPOLL_PWAIT2 +# define USE_EPOLL_PWAIT2 +# endif #endif /* HAVE_SYS_EPOLL_H && HAVE_EPOLL_CREATE */
#if defined(HAVE_PORT_H) && defined(HAVE_PORT_CREATE) @@ -564,6 +567,7 @@ static inline void remove_epoll_user( struct fd *fd, int user ) static inline void main_loop_epoll(void) { int i, ret, timeout; + struct timespec ts; struct epoll_event events[128];
assert( POLLIN == EPOLLIN ); @@ -575,12 +579,17 @@ static inline void main_loop_epoll(void)
while (active_users) { - timeout = get_next_timeout( NULL ); + timeout = get_next_timeout( &ts );
if (!active_users) break; /* last user removed by a timeout */ if (epoll_fd == -1) break; /* an error occurred with epoll */
+#ifdef USE_EPOLL_PWAIT2 + ret = epoll_pwait2( epoll_fd, events, ARRAY_SIZE( events ), timeout == -1 ? NULL : &ts, NULL ); +#else ret = epoll_wait( epoll_fd, events, ARRAY_SIZE( events ), timeout ); +#endif + set_current_time();
/* put the events into the pollfd array first, like poll does */