diff options
author | Martin Willi <martin@revosec.ch> | 2014-11-05 19:30:45 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2014-11-21 12:02:07 +0100 |
commit | 78725e68c1934742123fef647046078307e2bbc8 (patch) | |
tree | cbfb2a5daaa519bab67fc04838fef7d9e0e601d7 /src/libstrongswan/threading | |
parent | eeaa6f9b1a570ac559e1817378e99950d4a77560 (diff) | |
download | strongswan-78725e68c1934742123fef647046078307e2bbc8.tar.bz2 strongswan-78725e68c1934742123fef647046078307e2bbc8.tar.xz |
thread: Test for pending cancellation requests before poll()ing on OS X
As we are now using poll(2) instead of select(2), we need the work-around from
76dc329e for poll() as well.
Diffstat (limited to 'src/libstrongswan/threading')
-rw-r--r-- | src/libstrongswan/threading/thread.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstrongswan/threading/thread.h b/src/libstrongswan/threading/thread.h index 6abb83411..c6342321b 100644 --- a/src/libstrongswan/threading/thread.h +++ b/src/libstrongswan/threading/thread.h @@ -215,6 +215,26 @@ static inline int precancellable_select(int nfds, fd_set *restrict readfds, } #define select precancellable_select +#include <poll.h> + +/* + * The same as to select(2) applies to poll(2) + */ +static inline int precancellable_poll(struct pollfd fds[], nfds_t nfds, + int timeout) +{ + if (thread_cancelability(TRUE)) + { + thread_cancellation_point(); + } + else + { + thread_cancelability(FALSE); + } + return poll(fds, nfds, timeout); +} +#define poll precancellable_poll + #endif /* __APPLE__ */ #endif /** THREADING_THREAD_H_ @} */ |