[ Resending - I gotta get this moving soon. Patch is attached. ] > You're probably right. I'll see about getting an updated patch that > incorporates these changes.
OK, I've put together a new patch that implements the both the optimisation and the simpler _pollset_update() method. Attached to bug 27655: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27655 Rob. -- Robert Norris GPG: 1024D/FC18E6C2 Email+Jabber: [EMAIL PROTECTED] Web: http://cataclysm.cx/
diff -U3 -r ../../downloads/apr-0.9.4/include/apr_poll.h
apr-0.9.4/include/apr_poll.h
--- ../../downloads/apr-0.9.4/include/apr_poll.h 2003-03-06
08:22:26.000000000 +1100
+++ apr-0.9.4/include/apr_poll.h 2004-03-26 11:30:01.000000000 +1100
@@ -105,6 +105,9 @@
apr_socket_t *s; /**< socket */
} apr_descriptor;
+/** Reference to a descriptor in the underlying implementation */
+typedef struct apr_pollfd_ref_t apr_pollfd_ref_t;
+
/** @see apr_pollfd_t */
typedef struct apr_pollfd_t apr_pollfd_t;
@@ -115,6 +118,7 @@
apr_int16_t reqevents; /**< requested events */
apr_int16_t rtnevents; /**< returned events */
apr_descriptor desc; /**< @see apr_descriptor */
+ apr_pollfd_ref_t *ref; /**< @see apr_poll_ref_t */
void *client_data; /**< allows app to associate context */
};
@@ -259,7 +263,7 @@
* descriptor is signalled in apr_pollset_poll().
*/
APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
- const apr_pollfd_t *descriptor);
+ apr_pollfd_t *descriptor);
/**
* Remove a descriptor from a pollset
@@ -270,6 +274,14 @@
const apr_pollfd_t *descriptor);
/**
+ * Update the requested events for the descriptor in the underlying
implementation
+ * @param pollset The pollset that the descriptor is a member of
+ * @param descriptor The descriptor to update
+ */
+APR_DECLARE(apr_status_t) apr_pollset_update(apr_pollset_t *pollset,
+ apr_pollfd_t *descriptor);
+
+/**
* Block for activity on the descriptor(s) in a pollset
* @param pollset The pollset to use
* @param timeout Timeout in microseconds
diff -U3 -r ../../downloads/apr-0.9.4/poll/os2/pollset.c
apr-0.9.4/poll/os2/pollset.c
--- ../../downloads/apr-0.9.4/poll/os2/pollset.c 2003-01-07
10:44:36.000000000 +1100
+++ apr-0.9.4/poll/os2/pollset.c 2004-03-26 10:28:49.000000000 +1100
@@ -153,6 +153,18 @@
}
+APR_DECLARE(apr_status_t) apr_pollset_update(apr_pollset_t *pollset,
+ const apr_pollfd_t *descriptor)
+{
+ apr_status_t ret;
+
+ ret = apr_pollset_remove(pollset, descriptor);
+ if (ret != APR_SUCCESS)
+ return ret;
+
+ return apr_pollset_add(pollset, descriptor);
+}
+
static void make_pollset(apr_pollset_t *pollset)
{
diff -U3 -r ../../downloads/apr-0.9.4/poll/unix/poll.c
apr-0.9.4/poll/unix/poll.c
--- ../../downloads/apr-0.9.4/poll/unix/poll.c 2003-01-07 11:52:56.000000000
+1100
+++ apr-0.9.4/poll/unix/poll.c 2004-03-26 12:34:35.000000000 +1100
@@ -335,6 +335,14 @@
#endif
};
+
+#ifdef HAVE_POLL
+struct apr_pollfd_ref_t {
+ apr_uint32_t ref;
+};
+#endif
+
+
APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset,
apr_uint32_t size,
apr_pool_t *p,
@@ -375,16 +383,25 @@
}
APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
- const apr_pollfd_t *descriptor)
+ apr_pollfd_t *descriptor)
{
#ifndef HAVE_POLL
apr_os_sock_t fd;
+
+ if(descriptor->ref == NULL || descriptor->ref.ref == -1)
+ return APR_EBADF;
#endif
if (pollset->nelts == pollset->nalloc) {
return APR_ENOMEM;
}
+#ifdef HAVE_POLL
+ if(descriptor->ref == NULL)
+ descriptor->ref = apr_palloc(descriptor->p, sizeof(apr_pollfd_ref_t));
+ descriptor->ref->ref = pollset->nelts;
+#endif
+
pollset->query_set[pollset->nelts] = *descriptor;
#ifdef HAVE_POLL
@@ -396,6 +413,7 @@
}
pollset->pollset[pollset->nelts].events = get_event(descriptor->reqevents);
+
#else
if (descriptor->desc_type == APR_POLL_SOCKET) {
#ifdef NETWARE
@@ -454,24 +472,19 @@
#endif
#ifdef HAVE_POLL
- for (i = 0; i < pollset->nelts; i++) {
- if (descriptor->desc.s == pollset->query_set[i].desc.s) {
- /* Found an instance of the fd: remove this and any other copies */
- apr_uint32_t dst = i;
- apr_uint32_t old_nelts = pollset->nelts;
- pollset->nelts--;
- for (i++; i < old_nelts; i++) {
- if (descriptor->desc.s == pollset->query_set[i].desc.s) {
- pollset->nelts--;
- }
- else {
- pollset->pollset[dst] = pollset->pollset[i];
- pollset->query_set[dst] = pollset->query_set[i];
- dst++;
- }
- }
- return APR_SUCCESS;
+ i = descriptor->ref->ref;
+ descriptor->ref->ref = -1;
+ if (descriptor->desc.s == pollset->query_set[i].desc.s) {
+ apr_uint32_t dst = i;
+ apr_uint32_t old_nelts = pollset->nelts;
+ pollset->nelts--;
+ for (i++; i < old_nelts; i++) {
+ pollset->pollset[dst] = pollset->pollset[i];
+ pollset->query_set[dst] = pollset->query_set[i];
+ pollset->query_set[dst].ref->ref--;
+ dst++;
}
+ return APR_SUCCESS;
}
#else /* no poll */
@@ -515,6 +528,28 @@
return APR_NOTFOUND;
}
+APR_DECLARE(apr_status_t) apr_pollset_update(apr_pollset_t *pollset,
+ apr_pollfd_t *descriptor)
+{
+#ifdef HAVE_POLL
+ if(descriptor->ref == NULL || descriptor->ref->ref == -1)
+ return APR_EBADF;
+
+ pollset->pollset[descriptor->ref->ref].events =
get_event(descriptor->reqevents);
+ pollset->query_set[descriptor->ref->ref].reqevents = descriptor->reqevents;
+
+ return APR_SUCCESS;
+#else
+ apr_status_t ret;
+
+ ret = apr_pollset_remove(pollset, descriptor);
+ if (ret != APR_SUCCESS)
+ return ret;
+
+ return apr_pollset_add(pollset, descriptor);
+#endif
+}
+
#ifdef HAVE_POLL
APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
apr_interval_time_t timeout,
signature.asc
Description: Digital signature
