summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-11-20 17:40:16 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-11-20 17:40:16 +0000
commit5a4ee769ff4b6676b99111d89543a3bf63f86d8e (patch)
tree65bdef45539dff548afeb0cccb5bffae4aa660fb /network_io
parent1fff23d1b5d6d67077554cdb9ac02c3c7baa0d3d (diff)
downloadlibapr-5a4ee769ff4b6676b99111d89543a3bf63f86d8e.tar.gz
Getting closer to 1.0 - eliminate APR_SO_TIMEOUT and replace
various tests with (sock->timeout > 0). Also mop up some very hard to read statements by liberally applying parens. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64778 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r--network_io/os2/sockopt.c8
-rw-r--r--network_io/unix/sendrecv.c60
-rw-r--r--network_io/unix/sockets.c4
-rw-r--r--network_io/unix/sockopt.c10
-rw-r--r--network_io/win32/sockopt.c9
5 files changed, 29 insertions, 62 deletions
diff --git a/network_io/os2/sockopt.c b/network_io/os2/sockopt.c
index b188f90ea..63f5c9211 100644
--- a/network_io/os2/sockopt.c
+++ b/network_io/os2/sockopt.c
@@ -120,10 +120,6 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock,
return APR_OS2_STATUS(sock_errno());
}
}
- if (opt & APR_SO_TIMEOUT) {
- /* XXX: To be deprecated */
- return apr_socket_timeout_set(sock, on);
- }
if (opt & APR_TCP_NODELAY) {
if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) {
return APR_OS2_STATUS(sock_errno());
@@ -145,10 +141,6 @@ APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock,
apr_int32_t opt, apr_int32_t *on)
{
switch(opt) {
- case APR_SO_TIMEOUT:
- /* XXX: To be deprecated */
- *on = (apr_int32_t)sock->timeout;
- break;
default:
return APR_EINVAL;
}
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index 85ef64325..95d3a9047 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -80,7 +80,7 @@ apr_status_t apr_socket_send(apr_socket_t *sock, const char *buf,
} while (rv == -1 && errno == EINTR);
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
- && apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ && (sock->timeout > 0)) {
apr_status_t arv;
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -98,7 +98,7 @@ do_select:
*len = 0;
return errno;
}
- if (apr_is_option_set(sock, APR_SO_TIMEOUT) && rv < *len) {
+ if ((sock->timeout > 0) && (rv < *len)) {
sock->options |= APR_INCOMPLETE_WRITE;
}
(*len) = rv;
@@ -119,8 +119,8 @@ 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) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
@@ -137,7 +137,7 @@ do_select:
(*len) = 0;
return errno;
}
- if (apr_is_option_set(sock, APR_SO_TIMEOUT) && rv < *len) {
+ if ((sock->timeout > 0) && (rv < *len)) {
sock->options |= APR_INCOMPLETE_READ;
}
(*len) = rv;
@@ -159,8 +159,8 @@ 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)
- && apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -192,8 +192,8 @@ 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) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -239,8 +239,8 @@ 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) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
apr_status_t arv;
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -258,8 +258,7 @@ do_select:
*len = 0;
return errno;
}
- if (apr_is_option_set(sock, APR_SO_TIMEOUT) &&
- rv < requested_len) {
+ if ((sock->timeout > 0) && (rv < requested_len)) {
sock->options |= APR_INCOMPLETE_WRITE;
}
(*len) = rv;
@@ -338,9 +337,8 @@ 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 &&
- (errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -375,7 +373,7 @@ do_select:
* partial byte count; this is a non-blocking socket.
*/
- if (apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if (sock->timeout > 0) {
sock->options |= APR_INCOMPLETE_WRITE;
}
return arv;
@@ -523,7 +521,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file,
if (rv == -1) {
if (errno == EAGAIN) {
- if (apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if (sock->timeout > 0) {
sock->options |= APR_INCOMPLETE_WRITE;
}
/* FreeBSD's sendfile can return -1/EAGAIN even if it
@@ -561,9 +559,8 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file,
nbytes = 0;
}
}
- if (rv == -1 &&
- errno == EAGAIN &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN)
+ && (sock->timeout > 0)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -679,9 +676,8 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
}
} while (rc == -1 && errno == EINTR);
- if (rc == -1 &&
- (errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rc == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -827,9 +823,8 @@ apr_status_t apr_socket_sendfile(apr_socket_t * sock, apr_file_t * file,
flags); /* flags */
} while (rv == -1 && errno == EINTR);
- if (rv == -1 &&
- (errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+ && (sock->timeout > 0)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -857,8 +852,9 @@ do_select:
return errno;
}
- if (apr_is_option_set(sock, APR_SO_TIMEOUT) &&
- (parms.bytes_sent < (parms.file_bytes + parms.header_length + parms.trailer_length))) {
+ if ((sock->timeout > 0)
+ && (parms.bytes_sent
+ < (parms.file_bytes + parms.header_length + parms.trailer_length))) {
sock->options |= APR_INCOMPLETE_WRITE;
}
@@ -971,8 +967,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
if (nbytes) {
rv = 0;
}
- else if (!arv &&
- apr_is_option_set(sock, APR_SO_TIMEOUT) == 1) {
+ else if (!arv && (sock->timeout > 0)) {
apr_status_t t = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (t != APR_SUCCESS) {
@@ -993,8 +988,7 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
/* Update how much we sent */
*len = nbytes;
- if (apr_is_option_set(sock, APR_SO_TIMEOUT) &&
- (*len < requested_len)) {
+ if ((sock->timeout > 0) && (*len < requested_len)) {
sock->options |= APR_INCOMPLETE_WRITE;
}
return APR_SUCCESS;
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c
index 97c0eb2c4..342f619cc 100644
--- a/network_io/unix/sockets.c
+++ b/network_io/unix/sockets.c
@@ -271,8 +271,8 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
/* we can see EINPROGRESS the first time connect is called on a non-blocking
* socket; if called again, we can see EALREADY
*/
- if (rc == -1 && (errno == EINPROGRESS || errno == EALREADY) &&
- apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ if ((rc == -1) && (errno == EINPROGRESS || errno == EALREADY)
+ && (sock->timeout > 0)) {
rc = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (rc != APR_SUCCESS) {
return rc;
diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c
index c49809306..d89201d0e 100644
--- a/network_io/unix/sockopt.c
+++ b/network_io/unix/sockopt.c
@@ -144,8 +144,6 @@ apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
if (t <= 0) {
sock->options &= ~APR_INCOMPLETE_READ;
}
- sock->timeout = t;
- apr_set_option(sock, APR_SO_TIMEOUT, t > 0);
return APR_SUCCESS;
}
@@ -241,10 +239,6 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock,
return APR_ENOTIMPL;
#endif
break;
- case APR_SO_TIMEOUT:
- /* XXX: To be deprecated */
- return apr_socket_timeout_set(sock, on);
- break;
case APR_TCP_NODELAY:
#if defined(TCP_NODELAY)
if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) {
@@ -359,10 +353,6 @@ apr_status_t apr_socket_opt_get(apr_socket_t *sock,
apr_int32_t opt, apr_int32_t *on)
{
switch(opt) {
- case APR_SO_TIMEOUT:
- /* XXX: To be deprecated */
- *on = (apr_int32_t)sock->timeout;
- break;
default:
*on = apr_is_option_set(sock, opt);
}
diff --git a/network_io/win32/sockopt.c b/network_io/win32/sockopt.c
index a147ace64..bcb5822eb 100644
--- a/network_io/win32/sockopt.c
+++ b/network_io/win32/sockopt.c
@@ -133,11 +133,6 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock,
one = on ? 1 : 0;
switch (opt) {
- case APR_SO_TIMEOUT:
- {
- /* XXX: To be deprecated */
- return apr_socket_timeout_set(sock, on);
- }
case APR_SO_KEEPALIVE:
if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE,
@@ -243,10 +238,6 @@ APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock,
apr_int32_t opt, apr_int32_t *on)
{
switch (opt) {
- case APR_SO_TIMEOUT:
- /* XXX: to be deprecated */
- *on = (apr_int32_t)sock->timeout;
- break;
case APR_SO_DISCONNECTED:
*on = sock->disconnected;
break;