diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2022-01-27 14:21:39 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2022-01-27 14:21:39 +0000 |
commit | 7e1a9232431d950af5ce4532a924e6ea885ece2c (patch) | |
tree | c4ea9451b942e1d97ebe9e1732f3c4c982dfba04 | |
parent | 21cfbb9e47def2436772d33c98affc7842806144 (diff) | |
download | libapr-7e1a9232431d950af5ce4532a924e6ea885ece2c.tar.gz |
poll: Provide APR_POLLEXCL for exclusive wake up on systems that support it.
epoll has EPOLLEXCLUSIVE, start with that.
poll: Follow up to r1897521: struct epoll_event's events field is unsigned int.
EPOLLEXCLUSIVE is 1u << 28 so it doesn't fit in an int16_t, use unsigned for
the native epoll events type.
poll: Follow up to r1897521: Clarify what APR_POLLEXCL means.
This is to avoid the thundering herd issue when multiple threads/processes
poll on the same descriptor (usually listening/to-be-accept()ed descriptors).
Merge r1897521, r1897548, r1897549 from trunk.
Submitted by: ylavic
Reviewed by: ylavic
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897550 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | include/apr_poll.h | 1 | ||||
-rw-r--r-- | poll/unix/epoll.c | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/include/apr_poll.h b/include/apr_poll.h index 482d6ee1d..3cfbfc810 100644 --- a/include/apr_poll.h +++ b/include/apr_poll.h @@ -52,6 +52,7 @@ extern "C" { #define APR_POLLERR 0x010 /**< Pending error */ #define APR_POLLHUP 0x020 /**< Hangup occurred */ #define APR_POLLNVAL 0x040 /**< Descriptor invalid */ +#define APR_POLLEXCL 0x080 /**< Exclusive wake up */ /** @} */ /** diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c index c00a1094d..1652f9d27 100644 --- a/poll/unix/epoll.c +++ b/poll/unix/epoll.c @@ -25,9 +25,9 @@ #if defined(HAVE_EPOLL) -static apr_int16_t get_epoll_event(apr_int16_t event) +static unsigned get_epoll_event(apr_int16_t event) { - apr_int16_t rv = 0; + unsigned rv = 0; if (event & APR_POLLIN) rv |= EPOLLIN; @@ -35,12 +35,16 @@ static apr_int16_t get_epoll_event(apr_int16_t event) rv |= EPOLLPRI; if (event & APR_POLLOUT) rv |= EPOLLOUT; +#ifdef EPOLLEXCLUSIVE + if (event & APR_POLLEXCL) + rv |= EPOLLEXCLUSIVE; +#endif /* APR_POLLNVAL is not handled by epoll. EPOLLERR and EPOLLHUP are return-only */ return rv; } -static apr_int16_t get_epoll_revent(apr_int16_t event) +static apr_int16_t get_epoll_revent(unsigned event) { apr_int16_t rv = 0; |