Fixes hangs if Wine is built with newer headers than kernel
From: Alfred Agrell floating@muncher.se
Fixes: 87ca5db40e2c1b37423bdc25101a5c5e39e67e6f --- server/fd.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/server/fd.c b/server/fd.c index e1b969a0439..7324283b818 100644 --- a/server/fd.c +++ b/server/fd.c @@ -566,6 +566,9 @@ static inline void main_loop_epoll(void) int i, ret, timeout; struct timespec ts; struct epoll_event events[128]; +#ifdef HAVE_EPOLL_PWAIT2 + static int failed_epoll_pwait2 = 0; +#endif
assert( POLLIN == EPOLLIN ); assert( POLLOUT == EPOLLOUT ); @@ -582,10 +585,15 @@ static inline void main_loop_epoll(void) if (epoll_fd == -1) break; /* an error occurred with epoll */
#ifdef HAVE_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 ); + if (!failed_epoll_pwait2) + { + ret = epoll_pwait2( epoll_fd, events, ARRAY_SIZE( events ), timeout == -1 ? NULL : &ts, NULL ); + if (ret == -1 && errno == -ENOSYS) + failed_epoll_pwait2 = 1; + } + if (failed_epoll_pwait2) #endif + ret = epoll_wait( epoll_fd, events, ARRAY_SIZE( events ), timeout );
set_current_time();
cc @whrvt, you introduced this syscall (!7392)