summaryrefslogtreecommitdiffstats
path: root/rubbos/app/httpd-2.0.64/srclib/apr/poll
diff options
context:
space:
mode:
authorhongbotian <hongbo.tianhongbo@huawei.com>2015-11-30 01:45:08 -0500
committerhongbotian <hongbo.tianhongbo@huawei.com>2015-11-30 01:45:08 -0500
commite8ec7aa8e38a93f5b034ac74cebce5de23710317 (patch)
treeaa031937bf856c1f8d6ad7877b8d2cb0224da5ef /rubbos/app/httpd-2.0.64/srclib/apr/poll
parentcc40af334e619bb549038238507407866f774f8f (diff)
upload http
JIRA: BOTTLENECK-10 Change-Id: I7598427ff904df438ce77c2819ee48ac75ffa8da Signed-off-by: hongbotian <hongbo.tianhongbo@huawei.com>
Diffstat (limited to 'rubbos/app/httpd-2.0.64/srclib/apr/poll')
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/Makefile.in17
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/poll.c105
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollacc.c1
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollset.c220
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/poll.obin0 -> 20432 bytes
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/pollacc.obin0 -> 16824 bytes
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile17
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile.in17
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.c605
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.lo12
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.obin0 -> 20392 bytes
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.c152
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.lo12
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.obin0 -> 16768 bytes
14 files changed, 1158 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/Makefile.in
new file mode 100644
index 00000000..96fc006f
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/Makefile.in
@@ -0,0 +1,17 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+TARGETS = \
+ poll.lo \
+ pollset.lo \
+ pollacc.lo
+
+# bring in rules.mk for standard functionality
+@INCLUDE_RULES@
+
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/@OSDIR@
+DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/poll.c b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/poll.c
new file mode 100644
index 00000000..3c36e5e6
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/poll.c
@@ -0,0 +1,105 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_poll.h"
+#include "apr_arch_networkio.h"
+
+APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
+ apr_int32_t *nsds, apr_interval_time_t timeout)
+{
+ int *pollset;
+ int i;
+ int num_read = 0, num_write = 0, num_except = 0, num_total;
+ int pos_read, pos_write, pos_except;
+
+ for (i = 0; i < num; i++) {
+ if (aprset[i].desc_type == APR_POLL_SOCKET) {
+ num_read += (aprset[i].reqevents & APR_POLLIN) != 0;
+ num_write += (aprset[i].reqevents & APR_POLLOUT) != 0;
+ num_except += (aprset[i].reqevents & APR_POLLPRI) != 0;
+ }
+ }
+
+ num_total = num_read + num_write + num_except;
+ pollset = alloca(sizeof(int) * num_total);
+ memset(pollset, 0, sizeof(int) * num_total);
+
+ pos_read = 0;
+ pos_write = num_read;
+ pos_except = pos_write + num_write;
+
+ for (i = 0; i < num; i++) {
+ if (aprset[i].desc_type == APR_POLL_SOCKET) {
+ if (aprset[i].reqevents & APR_POLLIN) {
+ pollset[pos_read++] = aprset[i].desc.s->socketdes;
+ }
+
+ if (aprset[i].reqevents & APR_POLLOUT) {
+ pollset[pos_write++] = aprset[i].desc.s->socketdes;
+ }
+
+ if (aprset[i].reqevents & APR_POLLPRI) {
+ pollset[pos_except++] = aprset[i].desc.s->socketdes;
+ }
+
+ aprset[i].rtnevents = 0;
+ }
+ }
+
+ if (timeout > 0) {
+ timeout /= 1000; /* convert microseconds to milliseconds */
+ }
+
+ i = select(pollset, num_read, num_write, num_except, timeout);
+ (*nsds) = i;
+
+ if ((*nsds) < 0) {
+ return APR_FROM_OS_ERROR(sock_errno());
+ }
+
+ if ((*nsds) == 0) {
+ return APR_TIMEUP;
+ }
+
+ pos_read = 0;
+ pos_write = num_read;
+ pos_except = pos_write + num_write;
+
+ for (i = 0; i < num; i++) {
+ if (aprset[i].desc_type == APR_POLL_SOCKET) {
+ if (aprset[i].reqevents & APR_POLLIN) {
+ if (pollset[pos_read++] > 0) {
+ aprset[i].rtnevents |= APR_POLLIN;
+ }
+ }
+
+ if (aprset[i].reqevents & APR_POLLOUT) {
+ if (pollset[pos_write++] > 0) {
+ aprset[i].rtnevents |= APR_POLLOUT;
+ }
+ }
+
+ if (aprset[i].reqevents & APR_POLLPRI) {
+ if (pollset[pos_except++] > 0) {
+ aprset[i].rtnevents |= APR_POLLPRI;
+ }
+ }
+ }
+ }
+
+ return APR_SUCCESS;
+}
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollacc.c b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollacc.c
new file mode 100644
index 00000000..ac87d0aa
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollacc.c
@@ -0,0 +1 @@
+#include "../unix/pollacc.c"
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollset.c b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollset.c
new file mode 100644
index 00000000..872571f8
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/os2/pollset.c
@@ -0,0 +1,220 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_poll.h"
+#include "apr_arch_networkio.h"
+
+
+
+struct apr_pollset_t {
+ apr_pool_t *pool;
+ apr_uint32_t nelts;
+ apr_uint32_t nalloc;
+ int *pollset;
+ int num_read;
+ int num_write;
+ int num_except;
+ int num_total;
+ apr_pollfd_t *query_set;
+ apr_pollfd_t *result_set;
+};
+
+
+
+APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset,
+ apr_uint32_t size,
+ apr_pool_t *p,
+ apr_uint32_t flags)
+{
+ *pollset = apr_palloc(p, sizeof(**pollset));
+ (*pollset)->pool = p;
+ (*pollset)->nelts = 0;
+ (*pollset)->nalloc = size;
+ (*pollset)->pollset = apr_palloc(p, size * sizeof(int) * 3);
+ (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
+ (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
+ (*pollset)->num_read = -1;
+ return APR_SUCCESS;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset)
+{
+ /* A no-op function for now. If we later implement /dev/poll
+ * support, we'll need to close the /dev/poll fd here
+ */
+ return APR_SUCCESS;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
+ const apr_pollfd_t *descriptor)
+{
+ if (pollset->nelts == pollset->nalloc) {
+ return APR_ENOMEM;
+ }
+
+ pollset->query_set[pollset->nelts] = *descriptor;
+
+ if (descriptor->desc_type != APR_POLL_SOCKET) {
+ return APR_EBADF;
+ }
+
+ pollset->nelts++;
+ pollset->num_read = -1;
+ return APR_SUCCESS;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,
+ const apr_pollfd_t *descriptor)
+{
+ apr_uint32_t i;
+
+ 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++;
+ }
+ }
+
+ pollset->num_read = -1;
+ return APR_SUCCESS;
+ }
+ }
+
+ return APR_NOTFOUND;
+}
+
+
+
+static void make_pollset(apr_pollset_t *pollset)
+{
+ int i;
+ int pos = 0;
+
+ pollset->num_read = 0;
+ pollset->num_write = 0;
+ pollset->num_except = 0;
+
+ for (i = 0; i < pollset->nelts; i++) {
+ if (pollset->query_set[i].reqevents & APR_POLLIN) {
+ pollset->pollset[pos++] = pollset->query_set[i].desc.s->socketdes;
+ pollset->num_read++;
+ }
+ }
+
+ for (i = 0; i < pollset->nelts; i++) {
+ if (pollset->query_set[i].reqevents & APR_POLLOUT) {
+ pollset->pollset[pos++] = pollset->query_set[i].desc.s->socketdes;
+ pollset->num_write++;
+ }
+ }
+
+ for (i = 0; i < pollset->nelts; i++) {
+ if (pollset->query_set[i].reqevents & APR_POLLPRI) {
+ pollset->pollset[pos++] = pollset->query_set[i].desc.s->socketdes;
+ pollset->num_except++;
+ }
+ }
+
+ pollset->num_total = pollset->num_read + pollset->num_write + pollset->num_except;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
+ apr_interval_time_t timeout,
+ apr_int32_t *num,
+ const apr_pollfd_t **descriptors)
+{
+ int rv;
+ apr_uint32_t i;
+ int *pollresult;
+ int read_pos, write_pos, except_pos;
+
+ if (pollset->num_read < 0) {
+ make_pollset(pollset);
+ }
+
+ pollresult = alloca(sizeof(int) * pollset->num_total);
+ memcpy(pollresult, pollset->pollset, sizeof(int) * pollset->num_total);
+ (*num) = 0;
+
+ if (timeout > 0) {
+ timeout /= 1000;
+ }
+
+ rv = select(pollresult, pollset->num_read, pollset->num_write, pollset->num_except, timeout);
+
+ if (rv < 0) {
+ return APR_FROM_OS_ERROR(sock_errno());
+ }
+
+ if (rv == 0) {
+ return APR_TIMEUP;
+ }
+
+ read_pos = 0;
+ write_pos = pollset->num_read;
+ except_pos = pollset->num_read + pollset->num_write;
+
+ for (i = 0; i < pollset->nelts; i++) {
+ int rtnevents = 0;
+
+ if (pollset->query_set[i].reqevents & APR_POLLIN) {
+ if (pollresult[read_pos++] != -1) {
+ rtnevents |= APR_POLLIN;
+ }
+ }
+
+ if (pollset->query_set[i].reqevents & APR_POLLOUT) {
+ if (pollresult[write_pos++] != -1) {
+ rtnevents |= APR_POLLOUT;
+ }
+ }
+
+ if (pollset->query_set[i].reqevents & APR_POLLPRI) {
+ if (pollresult[except_pos++] != -1) {
+ rtnevents |= APR_POLLPRI;
+ }
+ }
+
+ if (rtnevents) {
+ pollset->result_set[*num] = pollset->query_set[i];
+ pollset->result_set[*num].rtnevents = rtnevents;
+ (*num)++;
+ }
+ }
+
+ *descriptors = pollset->result_set;
+ return APR_SUCCESS;
+}
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/poll.o b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/poll.o
new file mode 100644
index 00000000..3b0e57b9
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/poll.o
Binary files differ
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/pollacc.o b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/pollacc.o
new file mode 100644
index 00000000..d5a506db
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/.libs/pollacc.o
Binary files differ
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile
new file mode 100644
index 00000000..35ad9b16
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile
@@ -0,0 +1,17 @@
+srcdir = .
+
+
+TARGETS = \
+ poll.lo \
+ pollacc.lo
+
+
+# bring in rules.mk for standard functionality
+include /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/build/apr_rules.mk
+
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/unix
+DEFOSDIR=$(INCDIR)/arch/unix
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile.in
new file mode 100644
index 00000000..d9ab2219
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/Makefile.in
@@ -0,0 +1,17 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+TARGETS = \
+ poll.lo \
+ pollacc.lo
+
+
+# bring in rules.mk for standard functionality
+@INCLUDE_RULES@
+
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/@OSDIR@
+DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.c b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.c
new file mode 100644
index 00000000..dffda771
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.c
@@ -0,0 +1,605 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_poll.h"
+#include "apr_time.h"
+#include "apr_portable.h"
+#include "apr_arch_networkio.h"
+#include "apr_arch_file_io.h"
+#if HAVE_POLL_H
+#include <poll.h>
+#endif
+#if HAVE_SYS_POLL_H
+#include <sys/poll.h>
+#endif
+#if HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#ifdef NETWARE
+#define HAS_SOCKETS(dt) (dt == APR_POLL_SOCKET) ? 1 : 0
+#define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0
+#endif
+
+#ifdef HAVE_POLL /* We can just use poll to do our socket polling. */
+
+static apr_int16_t get_event(apr_int16_t event)
+{
+ apr_int16_t rv = 0;
+
+ if (event & APR_POLLIN)
+ rv |= POLLIN;
+ if (event & APR_POLLPRI)
+ rv |= POLLPRI;
+ if (event & APR_POLLOUT)
+ rv |= POLLOUT;
+ if (event & APR_POLLERR)
+ rv |= POLLERR;
+ if (event & APR_POLLHUP)
+ rv |= POLLHUP;
+ if (event & APR_POLLNVAL)
+ rv |= POLLNVAL;
+
+ return rv;
+}
+
+static apr_int16_t get_revent(apr_int16_t event)
+{
+ apr_int16_t rv = 0;
+
+ if (event & POLLIN)
+ rv |= APR_POLLIN;
+ if (event & POLLPRI)
+ rv |= APR_POLLPRI;
+ if (event & POLLOUT)
+ rv |= APR_POLLOUT;
+ if (event & POLLERR)
+ rv |= APR_POLLERR;
+ if (event & POLLHUP)
+ rv |= APR_POLLHUP;
+ if (event & POLLNVAL)
+ rv |= APR_POLLNVAL;
+
+ return rv;
+}
+
+#define SMALL_POLLSET_LIMIT 8
+
+APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
+ apr_int32_t *nsds, apr_interval_time_t timeout)
+{
+ int i, num_to_poll;
+#ifdef HAVE_VLA
+ /* XXX: I trust that this is a segv when insufficient stack exists? */
+ struct pollfd pollset[num];
+#elif defined(HAVE_ALLOCA)
+ struct pollfd *pollset = alloca(sizeof(struct pollfd) * num);
+ if (!pollset)
+ return APR_ENOMEM;
+#else
+ struct pollfd tmp_pollset[SMALL_POLLSET_LIMIT];
+ struct pollfd *pollset;
+
+ if (num <= SMALL_POLLSET_LIMIT) {
+ pollset = tmp_pollset;
+ }
+ else {
+ /* This does require O(n) to copy the descriptors to the internal
+ * mapping.
+ */
+ pollset = malloc(sizeof(struct pollfd) * num);
+ /* The other option is adding an apr_pool_abort() fn to invoke
+ * the pool's out of memory handler
+ */
+ if (!pollset)
+ return APR_ENOMEM;
+ }
+#endif
+ for (i = 0; i < num; i++) {
+ if (aprset[i].desc_type == APR_POLL_SOCKET) {
+ pollset[i].fd = aprset[i].desc.s->socketdes;
+ }
+ else if (aprset[i].desc_type == APR_POLL_FILE) {
+ pollset[i].fd = aprset[i].desc.f->filedes;
+ }
+ else {
+ break;
+ }
+ pollset[i].events = get_event(aprset[i].reqevents);
+ }
+ num_to_poll = i;
+
+ if (timeout > 0) {
+ timeout /= 1000; /* convert microseconds to milliseconds */
+ }
+
+ i = poll(pollset, num_to_poll, timeout);
+ (*nsds) = i;
+
+ for (i = 0; i < num; i++) {
+ aprset[i].rtnevents = get_revent(pollset[i].revents);
+ }
+
+#if !defined(HAVE_VLA) && !defined(HAVE_ALLOCA)
+ if (num > SMALL_POLLSET_LIMIT) {
+ free(pollset);
+ }
+#endif
+
+ if ((*nsds) < 0) {
+ return apr_get_netos_error();
+ }
+ if ((*nsds) == 0) {
+ return APR_TIMEUP;
+ }
+ return APR_SUCCESS;
+}
+
+
+#else /* Use select to mimic poll */
+
+APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, int num, apr_int32_t *nsds,
+ apr_interval_time_t timeout)
+{
+ fd_set readset, writeset, exceptset;
+ int rv, i;
+ int maxfd = -1;
+ struct timeval tv, *tvptr;
+#ifdef NETWARE
+ apr_datatype_e set_type = APR_NO_DESC;
+#endif
+
+ if (timeout < 0) {
+ tvptr = NULL;
+ }
+ else {
+ tv.tv_sec = (long)apr_time_sec(timeout);
+ tv.tv_usec = (long)apr_time_usec(timeout);
+ tvptr = &tv;
+ }
+
+ FD_ZERO(&readset);
+ FD_ZERO(&writeset);
+ FD_ZERO(&exceptset);
+
+ for (i = 0; i < num; i++) {
+ apr_os_sock_t fd;
+
+ aprset[i].rtnevents = 0;
+
+ if (aprset[i].desc_type == APR_POLL_SOCKET) {
+#ifdef NETWARE
+ if (HAS_PIPES(set_type)) {
+ return APR_EBADF;
+ }
+ else {
+ set_type = APR_POLL_SOCKET;
+ }
+#endif
+ fd = aprset[i].desc.s->socketdes;
+ }
+ else if (aprset[i].desc_type == APR_POLL_FILE) {
+#if !APR_FILES_AS_SOCKETS
+ return APR_EBADF;
+#else
+#ifdef NETWARE
+ if (aprset[i].desc.f->is_pipe && !HAS_SOCKETS(set_type)) {
+ set_type = APR_POLL_FILE;
+ }
+ else
+ return APR_EBADF;
+#endif /* NETWARE */
+
+ fd = aprset[i].desc.f->filedes;
+
+#endif /* APR_FILES_AS_SOCKETS */
+ }
+ else {
+ break;
+ }
+#if !defined(WIN32) && !defined(NETWARE) /* socket sets handled with array of handles */
+ if (fd >= FD_SETSIZE) {
+ /* XXX invent new error code so application has a clue */
+ return APR_EBADF;
+ }
+#endif
+ if (aprset[i].reqevents & APR_POLLIN) {
+ FD_SET(fd, &readset);
+ }
+ if (aprset[i].reqevents & APR_POLLOUT) {
+ FD_SET(fd, &writeset);
+ }
+ if (aprset[i].reqevents &
+ (APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) {
+ FD_SET(fd, &exceptset);
+ }
+ if ((int)fd > maxfd) {
+ maxfd = (int)fd;
+ }
+ }
+
+#ifdef NETWARE
+ if (HAS_PIPES(set_type)) {
+ rv = pipe_select(maxfd + 1, &readset, &writeset, &exceptset, tvptr);
+ }
+ else {
+#endif
+
+ rv = select(maxfd + 1, &readset, &writeset, &exceptset, tvptr);
+
+#ifdef NETWARE
+ }
+#endif
+
+ (*nsds) = rv;
+ if ((*nsds) == 0) {
+ return APR_TIMEUP;
+ }
+ if ((*nsds) < 0) {
+ return apr_get_netos_error();
+ }
+
+ for (i = 0; i < num; i++) {
+ apr_os_sock_t fd;
+
+ if (aprset[i].desc_type == APR_POLL_SOCKET) {
+ fd = aprset[i].desc.s->socketdes;
+ }
+ else if (aprset[i].desc_type == APR_POLL_FILE) {
+#if !APR_FILES_AS_SOCKETS
+ return APR_EBADF;
+#else
+ fd = aprset[i].desc.f->filedes;
+#endif
+ }
+ else {
+ break;
+ }
+ if (FD_ISSET(fd, &readset)) {
+ aprset[i].rtnevents |= APR_POLLIN;
+ }
+ if (FD_ISSET(fd, &writeset)) {
+ aprset[i].rtnevents |= APR_POLLOUT;
+ }
+ if (FD_ISSET(fd, &exceptset)) {
+ aprset[i].rtnevents |= APR_POLLERR;
+ }
+ }
+
+ return APR_SUCCESS;
+}
+
+#endif
+
+
+struct apr_pollset_t {
+ apr_uint32_t nelts;
+ apr_uint32_t nalloc;
+#ifdef HAVE_POLL
+ struct pollfd *pollset;
+#else
+ fd_set readset, writeset, exceptset;
+ int maxfd;
+#endif
+ apr_pollfd_t *query_set;
+ apr_pollfd_t *result_set;
+ apr_pool_t *pool;
+#ifdef NETWARE
+ int set_type;
+#endif
+};
+
+APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset,
+ apr_uint32_t size,
+ apr_pool_t *p,
+ apr_uint32_t flags)
+{
+#if !defined(HAVE_POLL) && defined(FD_SETSIZE)
+ if (size > FD_SETSIZE) {
+ *pollset = NULL;
+ return APR_EINVAL;
+ }
+#endif
+ *pollset = apr_palloc(p, sizeof(**pollset));
+ (*pollset)->nelts = 0;
+ (*pollset)->nalloc = size;
+#ifdef HAVE_POLL
+ (*pollset)->pollset = apr_palloc(p, size * sizeof(struct pollfd));
+#else
+ FD_ZERO(&((*pollset)->readset));
+ FD_ZERO(&((*pollset)->writeset));
+ FD_ZERO(&((*pollset)->exceptset));
+ (*pollset)->maxfd = 0;
+#ifdef NETWARE
+ (*pollset)->set_type = APR_NO_DESC;
+#endif
+#endif
+ (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
+ (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
+ (*pollset)->pool = p;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset)
+{
+ /* A no-op function for now. If we later implement /dev/poll
+ * support, we'll need to close the /dev/poll fd here
+ */
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset,
+ const apr_pollfd_t *descriptor)
+{
+#ifndef HAVE_POLL
+ apr_os_sock_t 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) {
+ pollset->pollset[pollset->nelts].fd = descriptor->desc.s->socketdes;
+ }
+ else {
+ pollset->pollset[pollset->nelts].fd = descriptor->desc.f->filedes;
+ }
+
+ pollset->pollset[pollset->nelts].events = get_event(descriptor->reqevents);
+#else
+ if (descriptor->desc_type == APR_POLL_SOCKET) {
+#ifdef NETWARE
+ /* NetWare can't handle mixed descriptor types in select() */
+ if (HAS_PIPES(pollset->set_type)) {
+ return APR_EBADF;
+ }
+ else {
+ pollset->set_type = APR_POLL_SOCKET;
+ }
+#endif
+ fd = descriptor->desc.s->socketdes;
+ }
+ else {
+#if !APR_FILES_AS_SOCKETS
+ return APR_EBADF;
+#else
+#ifdef NETWARE
+ /* NetWare can't handle mixed descriptor types in select() */
+ if (descriptor->desc.f->is_pipe && !HAS_SOCKETS(pollset->set_type)) {
+ pollset->set_type = APR_POLL_FILE;
+ fd = descriptor->desc.f->filedes;
+ }
+ else {
+ return APR_EBADF;
+ }
+#else
+ fd = descriptor->desc.f->filedes;
+#endif
+#endif
+ }
+#if !defined(WIN32) && !defined(NETWARE) /* socket sets handled with array of handles */
+ if (fd >= FD_SETSIZE) {
+ /* XXX invent new error code so application has a clue */
+ return APR_EBADF;
+ }
+#endif
+ if (descriptor->reqevents & APR_POLLIN) {
+ FD_SET(fd, &(pollset->readset));
+ }
+ if (descriptor->reqevents & APR_POLLOUT) {
+ FD_SET(fd, &(pollset->writeset));
+ }
+ if (descriptor->reqevents &
+ (APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) {
+ FD_SET(fd, &(pollset->exceptset));
+ }
+ if ((int)fd > pollset->maxfd) {
+ pollset->maxfd = (int)fd;
+ }
+#endif
+ pollset->nelts++;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,
+ const apr_pollfd_t *descriptor)
+{
+ apr_uint32_t i;
+#ifndef HAVE_POLL
+ apr_os_sock_t fd;
+#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;
+ }
+ }
+
+#else /* no poll */
+ if (descriptor->desc_type == APR_POLL_SOCKET) {
+ fd = descriptor->desc.s->socketdes;
+ }
+ else {
+#if !APR_FILES_AS_SOCKETS
+ return APR_EBADF;
+#else
+ fd = descriptor->desc.f->filedes;
+#endif
+ }
+
+ 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->query_set[dst] = pollset->query_set[i];
+ dst++;
+ }
+ }
+ FD_CLR(fd, &(pollset->readset));
+ FD_CLR(fd, &(pollset->writeset));
+ FD_CLR(fd, &(pollset->exceptset));
+ if (((int)fd == pollset->maxfd) && (pollset->maxfd > 0)) {
+ pollset->maxfd--;
+ }
+ return APR_SUCCESS;
+ }
+ }
+#endif /* no poll */
+
+ return APR_NOTFOUND;
+}
+
+#ifdef HAVE_POLL
+APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
+ apr_interval_time_t timeout,
+ apr_int32_t *num,
+ const apr_pollfd_t **descriptors)
+{
+ int rv;
+ apr_uint32_t i, j;
+
+ if (timeout > 0) {
+ timeout /= 1000;
+ }
+ rv = poll(pollset->pollset, pollset->nelts, timeout);
+ (*num) = rv;
+ if (rv < 0) {
+ return apr_get_netos_error();
+ }
+ if (rv == 0) {
+ return APR_TIMEUP;
+ }
+ j = 0;
+ for (i = 0; i < pollset->nelts; i++) {
+ if (pollset->pollset[i].revents != 0) {
+ pollset->result_set[j] = pollset->query_set[i];
+ pollset->result_set[j].rtnevents =
+ get_revent(pollset->pollset[i].revents);
+ j++;
+ }
+ }
+ *descriptors = pollset->result_set;
+ return APR_SUCCESS;
+}
+
+#else /* no poll */
+
+APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,
+ apr_interval_time_t timeout,
+ apr_int32_t *num,
+ const apr_pollfd_t **descriptors)
+{
+ int rv;
+ apr_uint32_t i, j;
+ struct timeval tv, *tvptr;
+ fd_set readset, writeset, exceptset;
+
+ if (timeout < 0) {
+ tvptr = NULL;
+ }
+ else {
+ tv.tv_sec = (long)apr_time_sec(timeout);
+ tv.tv_usec = (long)apr_time_usec(timeout);
+ tvptr = &tv;
+ }
+
+ memcpy(&readset, &(pollset->readset), sizeof(fd_set));
+ memcpy(&writeset, &(pollset->writeset), sizeof(fd_set));
+ memcpy(&exceptset, &(pollset->exceptset), sizeof(fd_set));
+
+#ifdef NETWARE
+ if (HAS_PIPES(pollset->set_type)) {
+ rv = pipe_select(pollset->maxfd + 1, &readset, &writeset, &exceptset, tvptr);
+ }
+ else
+#endif
+ rv = select(pollset->maxfd + 1, &readset, &writeset, &exceptset, tvptr);
+
+ /* Set initial *num now for expected -1 / 0 failures, or errors below */
+ (*num) = rv;
+ if (rv < 0) {
+ return apr_get_netos_error();
+ }
+ if (rv == 0) {
+ return APR_TIMEUP;
+ }
+ j = 0;
+ for (i = 0; i < pollset->nelts; i++) {
+ apr_os_sock_t fd;
+ if (pollset->query_set[i].desc_type == APR_POLL_SOCKET) {
+ fd = pollset->query_set[i].desc.s->socketdes;
+ }
+ else {
+#if !APR_FILES_AS_SOCKETS
+ return APR_EBADF;
+#else
+ fd = pollset->query_set[i].desc.f->filedes;
+#endif
+ }
+ if (FD_ISSET(fd, &readset) || FD_ISSET(fd, &writeset) ||
+ FD_ISSET(fd, &exceptset)) {
+ pollset->result_set[j] = pollset->query_set[i];
+ pollset->result_set[j].rtnevents = 0;
+ if (FD_ISSET(fd, &readset)) {
+ pollset->result_set[j].rtnevents |= APR_POLLIN;
+ }
+ if (FD_ISSET(fd, &writeset)) {
+ pollset->result_set[j].rtnevents |= APR_POLLOUT;
+ }
+ if (FD_ISSET(fd, &exceptset)) {
+ pollset->result_set[j].rtnevents |= APR_POLLERR;
+ }
+ j++;
+ }
+ }
+
+ /* Reset computed *num to account for multiply-polled fd's which
+ * select() - on some platforms, treats as a single fd result.
+ * The *num returned must match the size of result_set[]
+ */
+ (*num) = j;
+ *descriptors = pollset->result_set;
+ return APR_SUCCESS;
+}
+
+#endif /* no poll */
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.lo b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.lo
new file mode 100644
index 00000000..ee53f816
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.lo
@@ -0,0 +1,12 @@
+# poll.lo - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/poll.o'
+
+# Name of the non-PIC object.
+non_pic_object='poll.o'
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.o b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.o
new file mode 100644
index 00000000..d47744fd
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/poll.o
Binary files differ
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.c b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.c
new file mode 100644
index 00000000..3b1e3eb8
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.c
@@ -0,0 +1,152 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_poll.h"
+#include "apr_arch_networkio.h"
+#include "apr_arch_file_io.h"
+#if HAVE_POLL_H
+#include <poll.h>
+#endif
+#if HAVE_SYS_POLL_H
+#include <sys/poll.h>
+#endif
+
+APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num, apr_pool_t *cont)
+{
+ (*new) = (apr_pollfd_t *)apr_pcalloc(cont, sizeof(apr_pollfd_t) * (num + 1));
+ if ((*new) == NULL) {
+ return APR_ENOMEM;
+ }
+ (*new)[num].desc_type = APR_POLL_LASTDESC;
+ (*new)[0].p = cont;
+ return APR_SUCCESS;
+}
+
+static apr_pollfd_t *find_poll_sock(apr_pollfd_t *aprset, apr_socket_t *sock)
+{
+ apr_pollfd_t *curr = aprset;
+
+ while (curr->desc.s != sock) {
+ if (curr->desc_type == APR_POLL_LASTDESC) {
+ return NULL;
+ }
+ curr++;
+ }
+
+ return curr;
+}
+
+APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,
+ apr_socket_t *sock, apr_int16_t event)
+{
+ apr_pollfd_t *curr = aprset;
+
+ while (curr->desc_type != APR_NO_DESC) {
+ if (curr->desc_type == APR_POLL_LASTDESC) {
+ return APR_ENOMEM;
+ }
+ curr++;
+ }
+ curr->desc.s = sock;
+ curr->desc_type = APR_POLL_SOCKET;
+ curr->reqevents = event;
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event, apr_socket_t *sock, apr_pollfd_t *aprset)
+{
+ apr_pollfd_t *curr = find_poll_sock(aprset, sock);
+ if (curr == NULL) {
+ return APR_NOTFOUND;
+ }
+
+ (*event) = curr->rtnevents;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset,
+ apr_socket_t *sock, apr_int16_t events)
+{
+ apr_pollfd_t *curr = find_poll_sock(aprset, sock);
+ if (curr == NULL) {
+ return APR_NOTFOUND;
+ }
+
+ if (curr->reqevents & events) {
+ curr->reqevents ^= events;
+ }
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
+{
+ apr_pollfd_t *match = NULL;
+ apr_pollfd_t *curr;
+
+ for (curr = aprset; (curr->desc_type != APR_POLL_LASTDESC) &&
+ (curr->desc_type != APR_NO_DESC); curr++) {
+ if (curr->desc.s == sock) {
+ match = curr;
+ }
+ }
+ if (match == NULL) {
+ return APR_NOTFOUND;
+ }
+
+ /* Remove this entry by swapping the last entry into its place.
+ * This ensures that the non-APR_NO_DESC entries are all at the
+ * start of the array, so that apr_poll() doesn't have to worry
+ * about invalid entries in the middle of the pollset.
+ */
+ curr--;
+ if (curr != match) {
+ *match = *curr;
+ }
+ curr->desc_type = APR_NO_DESC;
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset, apr_int16_t events)
+{
+ apr_pollfd_t *curr = aprset;
+
+ while (curr->desc_type != APR_POLL_LASTDESC) {
+ if (curr->reqevents & events) {
+ curr->reqevents &= ~events;
+ }
+ curr++;
+ }
+ return APR_SUCCESS;
+}
+
+#if APR_FILES_AS_SOCKETS
+/* I'm not sure if this needs to return an apr_status_t or not, but
+ * for right now, we'll leave it this way, and change it later if
+ * necessary.
+ */
+APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock, apr_file_t *file)
+{
+ (*newsock) = apr_pcalloc(file->pool, sizeof(**newsock));
+ (*newsock)->socketdes = file->filedes;
+ (*newsock)->cntxt = file->pool;
+ (*newsock)->timeout = file->timeout;
+ return APR_SUCCESS;
+}
+#endif
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.lo b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.lo
new file mode 100644
index 00000000..d418c174
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.lo
@@ -0,0 +1,12 @@
+# pollacc.lo - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/pollacc.o'
+
+# Name of the non-PIC object.
+non_pic_object='pollacc.o'
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.o b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.o
new file mode 100644
index 00000000..18458749
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/poll/unix/pollacc.o
Binary files differ