summaryrefslogtreecommitdiff
path: root/poll
diff options
context:
space:
mode:
authorbrianp <brianp@13f79535-47bb-0310-9956-ffa450edef68>2002-08-02 01:13:49 +0000
committerbrianp <brianp@13f79535-47bb-0310-9956-ffa450edef68>2002-08-02 01:13:49 +0000
commit42eaec872d6b28cf7581aa20f35950c030b36177 (patch)
treeb51627fbf0a30dde3f473b2dcd363574658126c2 /poll
parent03dbf3d3b1519bd70d7a2b0246833170c897025a (diff)
downloadlibapr-42eaec872d6b28cf7581aa20f35950c030b36177.tar.gz
Remove some assumptions about file descriptors being integers
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63757 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poll')
-rw-r--r--poll/unix/poll.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index e316f9a38..f329d435d 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -307,22 +307,32 @@ APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset)
APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
const apr_pollfd_t *descriptor)
{
+#ifndef HAVE_POLL
int fd;
+#endif
+
if (pollset->nelts == pollset->nalloc) {
return APR_ENOMEM;
}
pollset->query_set[pollset->nelts] = *descriptor;
+#ifdef HAVE_POLL
+
if (descriptor->desc_type == APR_POLL_SOCKET) {
- fd = descriptor->desc.s->socketdes;
+ pollset->pollset[pollset->nelts].fd = descriptor->desc.s->socketdes;
}
else {
- fd = descriptor->desc.f->filedes;
+ pollset->pollset[pollset->nelts].fd = descriptor->desc.f->filedes;
}
-#ifdef HAVE_POLL
- pollset->pollset[pollset->nelts].fd = fd;
+
pollset->pollset[pollset->nelts].events = get_event(descriptor->reqevents);
#else
+ if (descriptor->desc_type == APR_POLL_SOCKET) {
+ fd = descriptor->desc.s->socketdes;
+ }
+ else {
+ fd = descriptor->desc.f->filedes;
+ }
if (descriptor->reqevents & APR_POLLIN) {
FD_SET(fd, &(pollset->readset));
}
@@ -345,24 +355,19 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,
const apr_pollfd_t *descriptor)
{
apr_uint32_t i;
+#ifndef HAVE_POLL
int fd;
-
- if (descriptor->desc_type == APR_POLL_SOCKET) {
- fd = descriptor->desc.s->socketdes;
- }
- else {
- fd = descriptor->desc.f->filedes;
- }
+#endif
#ifdef HAVE_POLL
for (i = 0; i < pollset->nelts; i++) {
- if (fd == pollset->pollset[i].fd) {
+ 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 (fd == pollset->pollset[i].fd) {
+ if (descriptor->desc.s == pollset->query_set[i].desc.s) {
pollset->nelts--;
}
else {
@@ -375,20 +380,21 @@ APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,
}
#else /* no poll */
+ if (descriptor->desc_type == APR_POLL_SOCKET) {
+ fd = descriptor->desc.s->socketdes;
+ }
+ else {
+ fd = descriptor->desc.f->filedes;
+ }
+
for (i = 0; i < pollset->nelts; i++) {
- if (((pollset->query_set[i].desc_type == APR_POLL_SOCKET) &&
- (fd == pollset->query_set[i].desc.s->socketdes)) ||
- ((pollset->query_set[i].desc_type == APR_POLL_FILE) &&
- (fd == pollset->query_set[i].desc.f->filedes))) {
+ 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 (((pollset->query_set[i].desc_type == APR_POLL_SOCKET) &&
- (fd == pollset->query_set[i].desc.s->socketdes)) ||
- ((pollset->query_set[i].desc_type == APR_POLL_FILE) &&
- (fd == pollset->query_set[i].desc.f->filedes))) {
+ if (descriptor->desc.s == pollset->query_set[i].desc.s) {
pollset->nelts--;
}
else {