rbb 2002/07/10 22:19:45
Modified: . CHANGES configure.in
file_io/unix readwrite.c
include apr_network_io.h
include/arch/unix networkio.h
network_io/unix Makefile.in sendrecv.c
test sendfile.c server.c testfile.c testpoll.c
Added: include apr_poll.h apr_support.h
poll/unix Makefile.in poll.c
support/unix Makefile.in waitio.c
Removed: network_io/unix poll.c
Log:
Reimplement apr_poll() on Unix. This improves performance by giving the
user back control over the memory in the pollset.
Revision Changes Path
1.305 +5 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.304
retrieving revision 1.305
diff -u -r1.304 -r1.305
--- CHANGES 9 Jul 2002 01:33:42 -0000 1.304
+++ CHANGES 11 Jul 2002 05:19:44 -0000 1.305
@@ -1,4 +1,9 @@
Changes with APR b1
+
+ *) Re-write apr_poll() on Unix. This improves the performance by
+ giving the user back control over the memory in the pollset.
+ [Ryan Bloom]
+
*) Added APR_LIMIT_NOFILE option to apr_procattr_limit_set() to
control the file descriptor limit on platforms that support
RLIMIT_NOFILE. [Brian Pane]
1.462 +1 -1 apr/configure.in
Index: configure.in
===================================================================
RCS file: /home/cvs/apr/configure.in,v
retrieving revision 1.461
retrieving revision 1.462
diff -u -r1.461 -r1.462
--- configure.in 10 Jul 2002 05:54:12 -0000 1.461
+++ configure.in 11 Jul 2002 05:19:44 -0000 1.462
@@ -82,7 +82,7 @@
DEFAULT_OSDIR="unix"
echo "(Default will be ${DEFAULT_OSDIR})"
-apr_modules="file_io network_io threadproc misc locks time mmap shmem i18n
user memory atomic"
+apr_modules="file_io network_io threadproc misc locks time mmap shmem i18n
user memory atomic poll support"
dnl Checks for programs.
AC_PROG_MAKE_SET
1.81 +3 -39 apr/file_io/unix/readwrite.c
Index: readwrite.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/readwrite.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- readwrite.c 4 Jul 2002 23:10:24 -0000 1.80
+++ readwrite.c 11 Jul 2002 05:19:44 -0000 1.81
@@ -55,6 +55,7 @@
#include "fileio.h"
#include "apr_strings.h"
#include "apr_thread_mutex.h"
+#include "apr_support.h"
/* The only case where we don't use wait_for_io_or_timeout is on
* pre-BONE BeOS, so this check should be sufficient and simpler */
@@ -62,43 +63,6 @@
#define USE_WAIT_FOR_IO
#endif
-#ifdef USE_WAIT_FOR_IO
-static apr_status_t wait_for_io_or_timeout(apr_file_t *file, int for_read)
-{
- struct timeval tv, *tvptr;
- fd_set fdset;
- int srv;
-
- /* TODO - timeout should be less each time through this loop */
-
- do {
- FD_ZERO(&fdset);
- FD_SET(file->filedes, &fdset);
- if (file->timeout >= 0) {
- tv.tv_sec = apr_time_sec(file->timeout);
- tv.tv_usec = apr_time_usec(file->timeout);
- tvptr = &tv;
- }
- else {
- tvptr = NULL;
- }
- srv = select(file->filedes + 1,
- for_read ? &fdset : NULL,
- for_read ? NULL : &fdset,
- NULL,
- tvptr);
- } while (srv == -1 && errno == EINTR);
-
- if (srv == 0) {
- return APR_TIMEUP;
- }
- else if (srv < 0) {
- return errno;
- }
- return APR_SUCCESS;
-}
-#endif
-
/* problems:
* 1) ungetchar not used for buffered files
*/
@@ -193,7 +157,7 @@
if (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
thefile->timeout != 0) {
- apr_status_t arv = wait_for_io_or_timeout(thefile, 1);
+ apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 1);
if (arv != APR_SUCCESS) {
*nbytes = bytes_read;
return arv;
@@ -272,7 +236,7 @@
if (rv == (apr_size_t)-1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
thefile->timeout != 0) {
- apr_status_t arv = wait_for_io_or_timeout(thefile, 0);
+ apr_status_t arv = apr_wait_for_io_or_timeout(thefile, NULL, 0);
if (arv != APR_SUCCESS) {
*nbytes = 0;
return arv;
1.125 +2 -118 apr/include/apr_network_io.h
Index: apr_network_io.h
===================================================================
RCS file: /home/cvs/apr/include/apr_network_io.h,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- apr_network_io.h 5 Jul 2002 17:58:10 -0000 1.124
+++ apr_network_io.h 11 Jul 2002 05:19:44 -0000 1.125
@@ -187,7 +187,6 @@
#endif
typedef struct apr_socket_t apr_socket_t;
-typedef struct apr_pollfd_t apr_pollfd_t;
/**
* A structure to encapsulate headers and trailers for apr_sendfile
*/
@@ -634,123 +633,6 @@
APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
const apr_sockaddr_t *addr2);
-/**
- * Setup the memory required for poll to operate properly
- * @param new_poll The poll structure to be used.
- * @param num The number of socket descriptors to be polled.
- * @param cont The pool to operate on.
- */
-APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new_poll,
- apr_int32_t num,
- apr_pool_t *cont);
-
-/**
- * Poll the sockets in the poll structure
- * @param aprset The poll structure we will be using.
- * @param nsds The number of sockets we are polling.
- * @param timeout The amount of time in microseconds to wait. This is
- * a maximum, not a minimum. If a socket is signalled, we
- * will wake up before this time. A negative number means
- * wait until a socket is signalled.
- * @remark
- * <PRE>
- * The number of sockets signalled is returned in the second argument.
- *
- * This is a blocking call, and it will not return until either a
- * socket has been signalled, or the timeout has expired.
- * </PRE>
- */
-APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t *nsds,
- apr_interval_time_t timeout);
-
-/**
- * Add a socket to the poll structure.
- * @param aprset The poll structure we will be using.
- * @param socket The socket to add to the current poll structure.
- * @param event The events to look for when we do the poll. One of:
- * <PRE>
- * APR_POLLIN signal if read will not block
- * APR_POLLPRI signal if prioirty data is availble to be read
- * APR_POLLOUT signal if write will not block
- * </PRE>
- */
-APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,
- apr_socket_t *sock,
- apr_int16_t event);
-
-/**
- * Modify a socket in the poll structure with mask.
- * @param aprset The poll structure we will be using.
- * @param sock The socket to modify in poll structure.
- * @param events The events to stop looking for during the poll. One of:
- * <PRE>
- * APR_POLLIN signal if read will not block
- * APR_POLLPRI signal if priority data is available to be
read
- * APR_POLLOUT signal if write will not block
- * </PRE>
- */
-APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset,
- apr_socket_t *sock,
- apr_int16_t events);
-/**
- * Remove a socket from the poll structure.
- * @param aprset The poll structure we will be using.
- * @param sock The socket to remove from the current poll structure.
- */
-APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset,
- apr_socket_t *sock);
-
-/**
- * Remove all sockets from the poll structure.
- * @param aprset The poll structure we will be using.
- * @param events The events to clear from all sockets. One of:
- * <PRE>
- * APR_POLLIN signal if read will not block
- * APR_POLLPRI signal if priority data is available to be
read
- * APR_POLLOUT signal if write will not block
- * </PRE>
- */
-APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset,
- apr_int16_t events);
-
-/**
- * Get the return events for the specified socket.
- * @param event The returned events for the socket. One of:
- * <PRE>
- * APR_POLLIN Data is available to be read
- * APR_POLLPRI Priority data is availble to be read
- * APR_POLLOUT Write will succeed
- * APR_POLLERR An error occurred on the socket
- * APR_POLLHUP The connection has been terminated
- * APR_POLLNVAL This is an invalid socket to poll on.
- * Socket not open.
- * </PRE>
- * @param sock The socket we wish to get information about.
- * @param aprset The poll structure we will be using.
- */
-APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event,
- apr_socket_t *sock,
- apr_pollfd_t *aprset);
-
-/**
- * Return the data associated with the current poll.
- * @param pollfd The currently open pollfd.
- * @param key The key to use for retrieving data associated with a poll
struct.
- * @param data The user data associated with the pollfd.
- */
-APR_DECLARE(apr_status_t) apr_poll_data_get(apr_pollfd_t *pollfd,
- const char *key, void *data);
-
-/**
- * Set the data associated with the current poll.
- * @param pollfd The currently open pollfd.
- * @param data The key to associate with the data.
- * @param key The user data to associate with the pollfd.
- * @param cleanup The cleanup function
- */
-APR_DECLARE(apr_status_t) apr_poll_data_set(apr_pollfd_t *pollfd, void *data,
- const char *key,
- apr_status_t (*cleanup)(void *));
#if APR_FILES_AS_SOCKETS || defined(DOXYGEN)
@@ -761,6 +643,8 @@
* @warning This is not available on all platforms. Platforms that have the
* ability to poll files for data to be read/written/exceptions will
* have the APR_FILES_AS_SOCKETS macro defined as true.
+ * @deprecated This function has been deprecated, because of the new poll
+ * implementation.
*/
APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock,
apr_file_t *file);
1.1 apr/include/apr_poll.h
Index: apr_poll.h
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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/>.
*/
#ifndef APR_POLL_H
#define APR_POLL_H
/**
* @file apr_network_io.h
* @brief APR Network library
*/
/**
* @defgroup APR_Net Network Routines
* @ingroup APR
* @{
*/
#include "apr.h"
#include "apr_pools.h"
#include "apr_errno.h"
#include "apr_inherit.h"
#include "apr_file_io.h"
#include "apr_network_io.h"
#if APR_HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @defgroup Poll options
* @{
*/
#define APR_POLLIN 0x001
#define APR_POLLPRI 0x002
#define APR_POLLOUT 0x004
#define APR_POLLERR 0x010
#define APR_POLLHUP 0x020
#define APR_POLLNVAL 0x040
/** @} */
typedef enum {
APR_NO_DESC,
APR_POLL_SOCKET,
APR_POLL_FILE,
APR_POLL_LASTDESC
} apr_datatype_e ;
typedef union {
apr_file_t *f;
apr_socket_t *s;
} apr_descriptor;
typedef struct apr_pollfd_t apr_pollfd_t;
struct apr_pollfd_t {
apr_pool_t *p;
apr_datatype_e desc_type;
apr_int16_t events;
apr_int16_t revents;
apr_descriptor desc;
};
/**
* Setup the memory required for poll to operate properly
* @param new_poll The poll structure to be used.
* @param num The number of socket descriptors to be polled.
* @param cont The pool to operate on.
* @deprecated This function is deprecated, APR applications should control
the pollset memory themselves.
*/
APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new_poll,
apr_int32_t num,
apr_pool_t *cont);
/**
* Poll the sockets in the poll structure
* @param aprset The poll structure we will be using.
* @param num The number of sockets we are polling
* @param nsds The number of sockets signalled.
* @param timeout The amount of time in microseconds to wait. This is
* a maximum, not a minimum. If a socket is signalled, we
* will wake up before this time. A negative number means
* wait until a socket is signalled.
* @remark
* <PRE>
* The number of sockets signalled is returned in the second argument.
*
* This is a blocking call, and it will not return until either a
* socket has been signalled, or the timeout has expired.
* </PRE>
*/
APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t numsock,
apr_int32_t *nsds,
apr_interval_time_t timeout);
/**
* Add a socket to the poll structure.
* @param aprset The poll structure we will be using.
* @param socket The socket to add to the current poll structure.
* @param event The events to look for when we do the poll. One of:
* <PRE>
* APR_POLLIN signal if read will not block
* APR_POLLPRI signal if prioirty data is availble to be read
* APR_POLLOUT signal if write will not block
* </PRE>
* @deprecated This function is deprecated, APR applications should control
the pollset memory themselves.
*/
APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,
apr_socket_t *sock,
apr_int16_t event);
/**
* Modify a socket in the poll structure with mask.
* @param aprset The poll structure we will be using.
* @param sock The socket to modify in poll structure.
* @param events The events to stop looking for during the poll. One of:
* <PRE>
* APR_POLLIN signal if read will not block
* APR_POLLPRI signal if priority data is available to be read
* APR_POLLOUT signal if write will not block
* </PRE>
* @deprecated This function is deprecated, APR applications should control
the pollset memory themselves.
*/
APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset,
apr_socket_t *sock,
apr_int16_t events);
/**
* Remove a socket from the poll structure.
* @param aprset The poll structure we will be using.
* @param sock The socket to remove from the current poll structure.
* @deprecated This function is deprecated, APR applications should control
the pollset memory themselves.
*/
APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset,
apr_socket_t *sock);
/**
* Remove all sockets from the poll structure.
* @param aprset The poll structure we will be using.
* @param events The events to clear from all sockets. One of:
* <PRE>
* APR_POLLIN signal if read will not block
* APR_POLLPRI signal if priority data is available to be read
* APR_POLLOUT signal if write will not block
* </PRE>
* @deprecated This function is deprecated, APR applications should control
the pollset memory themselves.
*/
APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset,
apr_int16_t events);
/**
* Get the return events for the specified socket.
* @param event The returned events for the socket. One of:
* <PRE>
* APR_POLLIN Data is available to be read
* APR_POLLPRI Priority data is availble to be read
* APR_POLLOUT Write will succeed
* APR_POLLERR An error occurred on the socket
* APR_POLLHUP The connection has been terminated
* APR_POLLNVAL This is an invalid socket to poll on.
* Socket not open.
* </PRE>
* @param sock The socket we wish to get information about.
* @param aprset The poll structure we will be using.
* @deprecated This function is deprecated, APR applications should control
the pollset memory themselves.
*/
APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event,
apr_socket_t *sock,
apr_pollfd_t *aprset);
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* ! APR_POLL_H */
1.1 apr/include/apr_support.h
Index: apr_support.h
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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/>.
*/
#ifndef APR_SUPPORT_H
#define APR_SUPPORT_H
/**
* @file apr_file_io.h
* @brief APR Support functions
*/
/**
* @defgroup APR_Support Internal APR support functions
* @ingroup APR_Support
* @{
*/
#include "apr.h"
#include "apr_network_io.h"
#include "apr_file_io.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
int for_read);
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* ! APR_SUPPORT_H */
1.54 +0 -30 apr/include/arch/unix/networkio.h
Index: networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/networkio.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- networkio.h 1 Apr 2002 14:13:45 -0000 1.53
+++ networkio.h 11 Jul 2002 05:19:44 -0000 1.54
@@ -69,12 +69,6 @@
#if APR_HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#endif
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
@@ -138,32 +132,8 @@
apr_int32_t inherit;
};
-struct apr_pollfd_t {
- apr_pool_t *cntxt;
-#ifdef HAVE_POLL
- struct pollfd *pollset;
- int num;
- int curpos;
-#else
- fd_set *read;
- fd_set *write;
- fd_set *except;
- int highsock;
- fd_set *read_set;
- fd_set *write_set;
- fd_set *except_set;
- apr_int16_t *events;
- apr_int16_t *revents;
-#ifdef BEOS
- int lowsock;
- int ncks;
-#endif
-#endif
-};
-
const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t
size);
int apr_inet_pton(int af, const char *src, void *dst);
-apr_status_t apr_wait_for_io_or_timeout(apr_socket_t *sock, int for_read);
void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t);
#define apr_is_option_set(mask, option) ((mask & option) ==option)
1.24 +0 -1 apr/network_io/unix/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/apr/network_io/unix/Makefile.in,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Makefile.in 22 Apr 2002 01:24:50 -0000 1.23
+++ Makefile.in 11 Jul 2002 05:19:44 -0000 1.24
@@ -2,7 +2,6 @@
VPATH = @srcdir@
TARGETS = \
- poll.lo \
sendrecv.lo \
sockets.lo \
sockopt.lo \
1.87 +13 -46 apr/network_io/unix/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- sendrecv.c 10 Jul 2002 06:01:12 -0000 1.86
+++ sendrecv.c 11 Jul 2002 05:19:44 -0000 1.87
@@ -53,6 +53,7 @@
*/
#include "networkio.h"
+#include "apr_support.h"
#if APR_HAS_SENDFILE
/* This file is needed to allow us access to the apr_file_t internals. */
@@ -63,40 +64,6 @@
#include <sys/sysctl.h>
#endif
-apr_status_t apr_wait_for_io_or_timeout(apr_socket_t *sock, int for_read)
-{
- struct timeval tv, *tvptr;
- fd_set fdset;
- int srv;
-
- do {
- FD_ZERO(&fdset);
- FD_SET(sock->socketdes, &fdset);
- if (sock->timeout < 0) {
- tvptr = NULL;
- }
- else {
- tv.tv_sec = sock->timeout / APR_USEC_PER_SEC;
- tv.tv_usec = sock->timeout % APR_USEC_PER_SEC;
- tvptr = &tv;
- }
- srv = select(sock->socketdes + 1,
- for_read ? &fdset : NULL,
- for_read ? NULL : &fdset,
- NULL,
- tvptr);
- /* TODO - timeout should be smaller on repeats of this loop */
- } while (srv == -1 && errno == EINTR);
-
- if (srv == 0) {
- return APR_TIMEUP;
- }
- else if (srv < 0) {
- return errno;
- }
- return APR_SUCCESS;
-}
-
apr_status_t apr_send(apr_socket_t *sock, const char *buf, apr_size_t *len)
{
apr_ssize_t rv;
@@ -114,7 +81,7 @@
&& sock->timeout != 0) {
apr_status_t arv;
do_select:
- arv = apr_wait_for_io_or_timeout(sock, 0);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -153,7 +120,7 @@
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout != 0) {
do_select:
- arv = apr_wait_for_io_or_timeout(sock, 1);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -191,7 +158,7 @@
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
&& sock->timeout != 0) {
- apr_status_t arv = apr_wait_for_io_or_timeout(sock, 0);
+ apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -224,7 +191,7 @@
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout != 0) {
- apr_status_t arv = apr_wait_for_io_or_timeout(sock, 1);
+ apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -272,7 +239,7 @@
sock->timeout != 0) {
apr_status_t arv;
do_select:
- arv = apr_wait_for_io_or_timeout(sock, 0);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -370,7 +337,7 @@
(errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout > 0) {
do_select:
- arv = apr_wait_for_io_or_timeout(sock, 0);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -528,7 +495,7 @@
if (sock->netmask & APR_INCOMPLETE_WRITE) {
apr_status_t arv;
sock->netmask &= ~APR_INCOMPLETE_WRITE;
- arv = apr_wait_for_io_or_timeout(sock, 0);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -590,7 +557,7 @@
if (rv == -1 &&
errno == EAGAIN &&
sock->timeout > 0) {
- apr_status_t arv = apr_wait_for_io_or_timeout(sock, 0);
+ apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -708,7 +675,7 @@
if (rc == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout > 0) {
- apr_status_t arv = apr_wait_for_io_or_timeout(sock, 0);
+ apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -847,7 +814,7 @@
(errno == EAGAIN || errno == EWOULDBLOCK) &&
sock->timeout > 0) {
do_select:
- arv = apr_wait_for_io_or_timeout(sock, 0);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -957,7 +924,7 @@
*/
if (sock->netmask & APR_INCOMPLETE_WRITE) {
sock->netmask &= ~APR_INCOMPLETE_WRITE;
- arv = apr_wait_for_io_or_timeout(sock, 0);
+ arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
return arv;
@@ -989,7 +956,7 @@
else if (!arv &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) == 1)
{
- apr_status_t t = apr_wait_for_io_or_timeout(sock, 0);
+ apr_status_t t = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (t != APR_SUCCESS)
{
1.1 apr/poll/unix/Makefile.in
Index: Makefile.in
===================================================================
srcdir = @srcdir@
VPATH = @srcdir@
TARGETS = \
poll.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
1.1 apr/poll/unix/poll.c
Index: poll.c
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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 "networkio.h"
#include "fileio.h"
#if HAVE_POLL_H
#include <poll.h>
#endif
#if HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif
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;
}
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_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->events = event;
return APR_SUCCESS;
}
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->revents;
return APR_SUCCESS;
}
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->events & events) {
curr->events ^= events;
}
return APR_SUCCESS;
}
apr_status_t apr_poll_socket_remove(apr_pollfd_t *aprset, apr_socket_t *sock)
{
apr_pollfd_t *curr = find_poll_sock(aprset, sock);
if (curr == NULL) {
return APR_NOTFOUND;
}
curr->desc_type = APR_NO_DESC;
return APR_SUCCESS;
}
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->events & events) {
curr->events &= ~events;
}
}
return APR_SUCCESS;
}
#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;
}
apr_status_t apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
apr_int32_t *nsds, apr_interval_time_t timeout)
{
/* obvious optimization, it would be better if this could be allocated
* on the stack. For a single file/socket, this can be otpimized
* very cleanly.
*/
struct pollfd *pollset = apr_palloc(aprset->p,
sizeof(struct pollfd) * num);
int i;
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;
}
pollset[i].events = get_event(aprset[i].events);
}
if (timeout > 0) {
timeout /= 1000; /* convert microseconds to milliseconds */
}
i = poll(pollset, num, timeout);
(*nsds) = i;
for (i = 0; i < num; i++) {
aprset[i].revents = get_revent(pollset[i].revents);
}
if ((*nsds) < 0) {
return errno;
}
if ((*nsds) == 0) {
return APR_TIMEUP;
}
return APR_SUCCESS;
}
#else /* Use select to mimic poll */
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;
if (timeout < 0) {
tvptr = NULL;
}
else {
tv.tv_sec = apr_time_sec(timeout);
tv.tv_usec = apr_time_usec(timeout);
tvptr = &tv;
}
FD_ZERO(&readset);
FD_ZERO(&writeset);
FD_ZERO(&exceptset);
for (i = 0; i < num; i++) {
int fd;
if (aprset[i].desc_type == APR_POLL_SOCKET) {
fd = aprset[i].desc.s->socketdes;
}
else if (aprset[i].desc_type == APR_POLL_FILE) {
fd = aprset[i].desc.f->filedes;
}
if (aprset[i].events & APR_POLLIN) {
FD_SET(fd, &readset);
}
if (aprset[i].events & APR_POLLOUT) {
FD_SET(fd, &writeset);
}
if (aprset[i].events &
(APR_POLLPRI | APR_POLLERR | APR_POLLHUP | APR_POLLNVAL)) {
FD_SET(fd, &exceptset);
}
if (fd > maxfd) {
maxfd = fd;
}
}
rv = select(maxfd + 1, &readset, &writeset, &exceptset, tvptr);
(*nsds) = rv;
if ((*nsds) == 0) {
return APR_TIMEUP;
}
if ((*nsds) < 0) {
return errno;
}
for (i = 0; i < num; i++) {
int fd;
if (aprset[i].desc_type == APR_POLL_SOCKET) {
fd = aprset[i].desc.s->socketdes;
}
else if (aprset[i].desc_type == APR_POLL_FILE) {
fd = aprset[i].desc.f->filedes;
}
aprset[i].revents = 0;
if (FD_ISSET(fd, &readset)) {
aprset[i].revents |= APR_POLLIN;
}
if (FD_ISSET(fd, &writeset)) {
aprset[i].revents |= APR_POLLOUT;
}
if (FD_ISSET(fd, &exceptset)) {
aprset[i].events |= APR_POLLERR;
}
}
return APR_SUCCESS;
}
#endif
#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_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
1.1 apr/support/unix/Makefile.in
Index: Makefile.in
===================================================================
srcdir = @srcdir@
VPATH = @srcdir@
TARGETS = \
waitio.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
1.1 apr/support/unix/waitio.c
Index: waitio.c
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 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 [EMAIL PROTECTED]
*
* 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 "fileio.h"
#include "networkio.h"
#include "apr_poll.h"
#include "apr_errno.h"
/* The only case where we don't use wait_for_io_or_timeout is on
* pre-BONE BeOS, so this check should be sufficient and simpler */
#if !BEOS_R5
#define USE_WAIT_FOR_IO
#endif
#ifdef USE_WAIT_FOR_IO
apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
int for_read)
{
apr_interval_time_t timeout;
apr_pollfd_t pollset;
int srv, n;
int type = for_read ? APR_POLLIN : APR_POLLOUT;
/* TODO - timeout should be less each time through this loop */
if (f) {
pollset.desc_type = APR_POLL_FILE;
pollset.desc.f = f;
pollset.p = f->pool;
timeout = f->timeout;
}
else {
pollset.desc_type = APR_POLL_SOCKET;
pollset.desc.s = s;
pollset.p = s->cntxt;
timeout = s->timeout;
}
pollset.events = type;
do {
srv = apr_poll(&pollset, 1, &n, timeout);
if (n == 1 && pollset.revents & type) {
return APR_SUCCESS;
}
} while (APR_STATUS_IS_EINTR(srv));
return srv;
}
#endif
1.21 +2 -1 apr/test/sendfile.c
Index: sendfile.c
===================================================================
RCS file: /home/cvs/apr/test/sendfile.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- sendfile.c 13 Mar 2002 20:39:27 -0000 1.20
+++ sendfile.c 11 Jul 2002 05:19:45 -0000 1.21
@@ -60,6 +60,7 @@
#include "apr_network_io.h"
#include "apr_errno.h"
#include "apr_general.h"
+#include "apr_poll.h"
#if !APR_HAS_SENDFILE
int main(void)
@@ -373,7 +374,7 @@
if (APR_STATUS_IS_EAGAIN(rv)) {
assert(tmplen == 0);
nsocks = 1;
- tmprv = apr_poll(pfd, &nsocks, -1);
+ tmprv = apr_poll(pfd, 1, &nsocks, -1);
assert(!tmprv);
assert(nsocks == 1);
/* continue; */
1.35 +2 -1 apr/test/server.c
Index: server.c
===================================================================
RCS file: /home/cvs/apr/test/server.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- server.c 13 Mar 2002 20:39:27 -0000 1.34
+++ server.c 11 Jul 2002 05:19:45 -0000 1.35
@@ -58,6 +58,7 @@
#include <stdlib.h>
#include "apr_network_io.h"
#include "apr_getopt.h"
+#include "apr_poll.h"
#define STRLEN 15
@@ -138,7 +139,7 @@
pollres = 1;
APR_TEST_BEGIN(rv, "Polling for socket",
- apr_poll(sdset, &pollres, -1))
+ apr_poll(sdset, 1, &pollres, -1))
if (pollres == 0) {
fprintf(stdout, "Failed\n");
1.50 +2 -1 apr/test/testfile.c
Index: testfile.c
===================================================================
RCS file: /home/cvs/apr/test/testfile.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- testfile.c 5 Jul 2002 00:26:36 -0000 1.49
+++ testfile.c 11 Jul 2002 05:19:45 -0000 1.50
@@ -61,6 +61,7 @@
#include "apr_network_io.h"
#include "apr_errno.h"
#include "apr_general.h"
+#include "apr_poll.h"
#include "apr_lib.h"
#include "test_apr.h"
@@ -157,7 +158,7 @@
apr_poll_socket_add(sdset, testsock, APR_POLLIN);
num = 1;
STD_TEST_NEQ(" Checking for incoming data",
- apr_poll(sdset, &num, apr_time_from_sec(1)));
+ apr_poll(sdset, 1, &num, apr_time_from_sec(1)));
if (num == 0) {
printf("** This platform doesn't return readability on a regular
file.**\n");
}
1.9 +7 -6 apr/test/testpoll.c
Index: testpoll.c
===================================================================
RCS file: /home/cvs/apr/test/testpoll.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- testpoll.c 13 Mar 2002 20:39:27 -0000 1.8
+++ testpoll.c 11 Jul 2002 05:19:45 -0000 1.9
@@ -57,6 +57,7 @@
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_network_io.h"
+#include "apr_poll.h"
#if APR_HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -145,7 +146,7 @@
apr_socket_t *s[3];
apr_sockaddr_t *sa[3];
apr_pollfd_t *pollset;
- int i = 0, srv = 0;
+ int i = 0, srv = 3;
fprintf (stdout,"APR Poll Test\n*************\n\n");
@@ -186,29 +187,29 @@
printf("OK\n");
printf("Starting Tests\n");
- apr_poll(pollset, &srv, 10);
+ apr_poll(pollset, 3, &srv, 10);
check_sockets(pollset, s);
send_msg(s, sa, 2);
- apr_poll(pollset, &srv, 10);
+ apr_poll(pollset, 3, &srv, 10);
check_sockets(pollset, s);
recv_msg(s, 2, context);
send_msg(s, sa, 1);
- apr_poll(pollset, &srv, 10);
+ apr_poll(pollset, 3, &srv, 10);
check_sockets(pollset, s);
send_msg(s, sa, 2);
- apr_poll(pollset, &srv, 10);
+ apr_poll(pollset, 3, &srv, 10);
check_sockets(pollset, s);
recv_msg(s, 1, context);
send_msg(s, sa, 0);
- apr_poll(pollset, &srv, 10);
+ apr_poll(pollset, 3, &srv, 10);
check_sockets(pollset, s);
printf("Tests completed.\n");