summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwsanchez <wsanchez@13f79535-47bb-0310-9956-ffa450edef68>2005-05-28 00:06:36 +0000
committerwsanchez <wsanchez@13f79535-47bb-0310-9956-ffa450edef68>2005-05-28 00:06:36 +0000
commit1d49eedf99d30314c341cef6cbd8145fd099ca82 (patch)
treefb8eead69c4158bfcda0436c1d37cb3896539745
parent476bcda174dd7f7cb3b85109633197b1aea7ea79 (diff)
downloadlibapr-1d49eedf99d30314c341cef6cbd8145fd099ca82.tar.gz
Backport r178340 from trunk:
network_io/unix/sendrecv.c: Deal with EAGAIN after poll(). Following apr_wait_for_io_or_timeout(), we were doing I/O and not dealing with EAGAIN. It is legal for poll() to indicate that a socket is available for writing and then for write() to fail with EAGAIN if the state of the socket changed in between the poll() and write() calls. This only seems to actually happen on Mac OS 10.4 (Darwin 8). Rather than trying write() only once, if we get an EAGAIN, continue to call apr_wait_for_io_or_timeout() and try writing. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@178842 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES3
-rw-r--r--network_io/unix/sendrecv.c16
2 files changed, 11 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index be3b56511..44640a4eb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with APR 0.9.7
*) Fix detection of rwlocks on Mac OS X. [Aaron Bannert]
+ *) Fix issue with poll() followed by net I/O yielding EAGAIN on
+ Mac OS 10.4 (Darwin 8). [Wilfredo Sanchez]
+
Changes with APR 0.9.6
*) Add apr_threadattr_stacksize_set() for overriding the default
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index 40f04c904..3cd07629a 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -41,7 +41,7 @@ apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf,
rv = write(sock->socketdes, buf, (*len));
} while (rv == -1 && errno == EINTR);
- if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
+ while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
&& apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
apr_status_t arv;
do_select:
@@ -81,7 +81,7 @@ apr_status_t apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len)
rv = read(sock->socketdes, buf, (*len));
} while (rv == -1 && errno == EINTR);
- if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
+ while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
@@ -121,7 +121,7 @@ apr_status_t apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
where->salen);
} while (rv == -1 && errno == EINTR);
- if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
+ while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
&& apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -154,7 +154,7 @@ apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
(struct sockaddr*)&from->sa, &from->salen);
} while (rv == -1 && errno == EINTR);
- if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
+ while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
@@ -201,7 +201,7 @@ apr_status_t apr_socket_sendv(apr_socket_t * sock, const struct iovec *vec,
rv = writev(sock->socketdes, vec, nvec);
} while (rv == -1 && errno == EINTR);
- if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
+ while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
apr_status_t arv;
do_select:
@@ -300,7 +300,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
*len); /* number of bytes to send */
} while (rv == -1 && errno == EINTR);
- if (rv == -1 &&
+ while (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
do_select:
@@ -641,7 +641,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
}
} while (rc == -1 && errno == EINTR);
- if (rc == -1 &&
+ while (rc == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -789,7 +789,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file,
flags); /* flags */
} while (rv == -1 && errno == EINTR);
- if (rv == -1 &&
+ while (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
do_select: