diff options
author | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2003-11-17 01:41:18 +0000 |
---|---|---|
committer | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2003-11-17 01:41:18 +0000 |
commit | 4825d7e302a225991dec3d211c9ff42ba90b5039 (patch) | |
tree | 3a246b886518c4c5ac54eb4381929d7cd4d6659f /network_io | |
parent | 5703b123e764ea25f6c02096bca7ad701126c22d (diff) | |
download | libapr-4825d7e302a225991dec3d211c9ff42ba90b5039.tar.gz |
With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
needed to be rebuilt. Specifically, it needs a pollset, but we don't want
to allocate that all the time. Thus, we need to create it once at socket
or file creation time, and then reuse that pollset.
NOTE: this makes the library compile, but some of the test programs may
not. I have also not verified this work yet (in favor of just getting it
to at least compile...)
For the apr_arch_*.h files, I added a pollset member to the file and
socket structures.
For the various open/dup/etc functions, I added the creation of that
pollset whenever a file or socket is created.
(I may have missed some and will verify further)
For the socket create and sendrecv function, I added the creation of the
pollset.
(again, may have missed some, but if everybody uses alloc_socket, then we
should be okay)
* support/unix/waitio.c: rebuild in terms of the pollset
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64759 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/beos/sendrecv.c | 10 | ||||
-rw-r--r-- | network_io/os2/sockets.c | 6 | ||||
-rw-r--r-- | network_io/unix/sockets.c | 5 | ||||
-rw-r--r-- | network_io/win32/sockets.c | 4 |
4 files changed, 20 insertions, 5 deletions
diff --git a/network_io/beos/sendrecv.c b/network_io/beos/sendrecv.c index 965ea8857..58bbced43 100644 --- a/network_io/beos/sendrecv.c +++ b/network_io/beos/sendrecv.c @@ -59,7 +59,7 @@ #include "apr_arch_networkio.h" #include "apr_time.h" -apr_status_t apr_wait_for_io_or_timeout(apr_socket_t *sock, int for_read) +static apr_status_t wait_for_io_or_timeout(apr_socket_t *sock, int for_read) { struct timeval tv, *tvptr; fd_set fdset; @@ -139,7 +139,7 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, } while (rv == -1 && errno == EINTR); if (rv == -1 && errno == EWOULDBLOCK && sock->timeout > 0) { - apr_status_t arv = apr_wait_for_io_or_timeout(sock, 1); + apr_status_t arv = wait_for_io_or_timeout(sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -185,7 +185,7 @@ APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, 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 = wait_for_io_or_timeout(sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -226,7 +226,7 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, 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 = wait_for_io_or_timeout(sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; @@ -249,4 +249,4 @@ APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, return APR_SUCCESS; } -#endif +#endif /* ! BEOS_BONE */ diff --git a/network_io/os2/sockets.c b/network_io/os2/sockets.c index 5c13fe39f..66949b573 100644 --- a/network_io/os2/sockets.c +++ b/network_io/os2/sockets.c @@ -103,6 +103,10 @@ static void alloc_socket(apr_socket_t **new, apr_pool_t *p) (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->cntxt, sizeof(apr_sockaddr_t)); (*new)->remote_addr->pool = p; + + /* Create a pollset with room for one descriptor. */ + /* ### check return codes */ + (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); } APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, int *protocol) @@ -115,6 +119,7 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, int int protocol, apr_pool_t *cont) { int downgrade = (family == AF_UNSPEC); + apr_pollfd_t pfd; if (family == AF_UNSPEC) { #if APR_HAVE_IPV6 @@ -143,6 +148,7 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int family, int (*new)->nonblock = FALSE; apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), socket_cleanup, apr_pool_cleanup_null); + return APR_SUCCESS; } diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c index 26a90d5e2..97c0eb2c4 100644 --- a/network_io/unix/sockets.c +++ b/network_io/unix/sockets.c @@ -103,6 +103,10 @@ static void alloc_socket(apr_socket_t **new, apr_pool_t *p) (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->cntxt, sizeof(apr_sockaddr_t)); (*new)->remote_addr->pool = p; + + /* Create a pollset with room for one descriptor. */ + /* ### check return codes */ + (void) apr_pollset_create(&(*new)->pollset, 1, p, 0); } apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol) @@ -144,6 +148,7 @@ apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, (*new)->inherit = 0; apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), socket_cleanup, socket_cleanup); + return APR_SUCCESS; } diff --git a/network_io/win32/sockets.c b/network_io/win32/sockets.c index 5ef459e5e..fffbc7c71 100644 --- a/network_io/win32/sockets.c +++ b/network_io/win32/sockets.c @@ -94,6 +94,10 @@ static void alloc_socket(apr_socket_t **new, apr_pool_t *p) (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->cntxt, sizeof(apr_sockaddr_t)); (*new)->remote_addr->pool = p; + + /* Create a pollset with room for one descriptor. */ + /* ### check return codes */ + (void) apr_pollset_create(&(*new)->pollset, 1, cont, 0); } APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, |