Hello developers,
When using apr_pollset_poll, I missed the Edge Trigered behavior. In the
epoll manual it's the recommended way of use. Epoll is most efficient when
used with Edge Trigered interface... It's Linux specific it's not portable
but including extra APR_ flags won't hurt. The Platforms that do not support
it will simply take no effect. The patch is included, your commens &&
questions are welcome. Note* The patch is against apr 1.2.8, but it will
cleanly apply against SVN, tested.
Comments && questions welcome.
diff -Naurb apr-1.2.8/include/apr_poll.h apr_nodoc/include/apr_poll.h
--- apr-1.2.8/include/apr_poll.h 2006-08-03 14:05:27.000000000 +0300
+++ apr_nodoc/include/apr_poll.h 2007-03-20 11:57:09.000000000 +0200
@@ -52,6 +52,14 @@
#define APR_POLLNVAL 0x040 /**< Descriptior invalid */
/**
+ * added by Mindaugas Janusaitis <[EMAIL PROTECTED]>
+ */
+
+#define APR_POLLRDHUP 0x100 /**< Reader Hangup occurred */
+#define APR_POLLET 0x200 /**< Epoll Edge Trigered Behavior */
+
+
+/**
* Pollset Flags
*/
#define APR_POLLSET_THREADSAFE 0x001 /**< Adding or Removing a Descriptor is thread safe */
@@ -77,8 +85,8 @@
struct apr_pollfd_t {
apr_pool_t *p; /**< associated pool */
apr_datatype_e desc_type; /**< descriptor type */
- apr_int16_t reqevents; /**< requested events */
- apr_int16_t rtnevents; /**< returned events */
+ apr_uint32_t reqevents; /**< requested events */
+ apr_uint32_t rtnevents; /**< returned events */
apr_descriptor desc; /**< @see apr_descriptor */
void *client_data; /**< allows app to associate context */
};
diff -Naurb apr-1.2.8/poll/unix/epoll.c apr_nodoc/poll/unix/epoll.c
--- apr-1.2.8/poll/unix/epoll.c 2006-08-03 14:05:27.000000000 +0300
+++ apr_nodoc/poll/unix/epoll.c 2007-03-20 12:34:08.000000000 +0200
@@ -18,9 +18,15 @@
#ifdef POLLSET_USES_EPOLL
-static apr_int16_t get_epoll_event(apr_int16_t event)
+#ifndef EPOLLRDHUP
+#define EPOLLRDHUP 0x2000
+#endif
+
+
+
+static apr_uint32_t get_epoll_event(apr_uint32_t event)
{
- apr_int16_t rv = 0;
+ apr_uint32_t rv = 0;
if (event & APR_POLLIN)
rv |= EPOLLIN;
@@ -32,14 +38,20 @@
rv |= EPOLLERR;
if (event & APR_POLLHUP)
rv |= EPOLLHUP;
+ if (event & APR_POLLRDHUP)
+ rv |= EPOLLRDHUP;
+ if (event & APR_POLLET)
+ rv |= EPOLLET;
+
/* APR_POLLNVAL is not handled by epoll. */
return rv;
}
-static apr_int16_t get_epoll_revent(apr_int16_t event)
+
+static apr_uint32_t get_epoll_revent(apr_uint32_t event)
{
- apr_int16_t rv = 0;
+ apr_uint32_t rv = 0;
if (event & EPOLLIN)
rv |= APR_POLLIN;
@@ -51,6 +63,11 @@
rv |= APR_POLLERR;
if (event & EPOLLHUP)
rv |= APR_POLLHUP;
+ if (event & EPOLLRDHUP)
+ rv |= APR_POLLRDHUP;
+ if (event & EPOLLET)
+ rv |= APR_POLLET;
+
/* APR_POLLNVAL is not handled by epoll. */
return rv;