summaryrefslogtreecommitdiff
path: root/poll
diff options
context:
space:
mode:
authorgstein <gstein@13f79535-47bb-0310-9956-ffa450edef68>2003-11-17 00:32:36 +0000
committergstein <gstein@13f79535-47bb-0310-9956-ffa450edef68>2003-11-17 00:32:36 +0000
commitf6d39b12878facff117c8a5124cb7251cf1d25c8 (patch)
tree82888df4d9dbe198b15fac612259aa711819318b /poll
parent9b5b6e7d455d4953eeae57f89e431cd94036fcb7 (diff)
downloadlibapr-f6d39b12878facff117c8a5124cb7251cf1d25c8.tar.gz
Remove the old/deprecated apr_poll interface.
* include/apr_poll.h: (apr_poll, apr_poll_setup, apr_poll_socket_add, apr_poll_socket_mask, apr_poll_socket_remove, apr_poll_socket_clear, apr_poll_revents_get): removed. these were deprecated a while back, in favor of the apr_pollset_t interfaces. * poll/os2/poll.c: removed. this implemented apr_poll() which was deprecated by the new apr_pollset_t interfaces. * poll/os/Makefile.in: remove reference to poll.lo * poll/unix/poll.c: - remove include of alloca.h; no longer needed (apr_poll): removed both implementations * poll/unix/pollacc.c: (apr_poll_setup, apr_poll_socket_add, apr_poll_socket_mask, apr_poll_socket_remove, apr_poll_socket_clear, apr_poll_revents_get): removed these deprecated functions. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64757 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poll')
-rwxr-xr-xpoll/os2/Makefile.in1
-rwxr-xr-xpoll/os2/poll.c143
-rw-r--r--poll/unix/poll.c207
-rw-r--r--poll/unix/pollacc.c120
4 files changed, 5 insertions, 466 deletions
diff --git a/poll/os2/Makefile.in b/poll/os2/Makefile.in
index 96fc006fe..9ebedb01e 100755
--- a/poll/os2/Makefile.in
+++ b/poll/os2/Makefile.in
@@ -2,7 +2,6 @@ srcdir = @srcdir@
VPATH = @srcdir@
TARGETS = \
- poll.lo \
pollset.lo \
pollacc.lo
diff --git a/poll/os2/poll.c b/poll/os2/poll.c
deleted file mode 100755
index ed36dc887..000000000
--- a/poll/os2/poll.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#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/poll/unix/poll.c b/poll/unix/poll.c
index 05d30b7d1..3578d17e2 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -64,15 +64,14 @@
#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)
@@ -115,207 +114,7 @@ static apr_int16_t get_revent(apr_int16_t event)
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 (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
+#endif /* HAVE_POLL */
struct apr_pollset_t {
diff --git a/poll/unix/pollacc.c b/poll/unix/pollacc.c
index 2473b0d79..275895811 100644
--- a/poll/unix/pollacc.c
+++ b/poll/unix/pollacc.c
@@ -53,133 +53,17 @@
*/
#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)
+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;