wrowe 2003/11/20 09:40:16
Modified: . CHANGES
include apr_network_io.h
network_io/os2 sockopt.c
network_io/unix sendrecv.c sockets.c sockopt.c
network_io/win32 sockopt.c
Log:
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.
Revision Changes Path
1.441 +10 -5 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.440
retrieving revision 1.441
diff -u -r1.440 -r1.441
--- CHANGES 16 Nov 2003 01:33:01 -0000 1.440
+++ CHANGES 20 Nov 2003 17:40:16 -0000 1.441
@@ -1,13 +1,18 @@
-Changes with APR 1.0
-
- *) Change i386 FreeBSD to use the asm routines in apr_atomic.h
- to overcome issues with the FreeBSD atomic functions return
- type on i386. [David Reid]
+Changes for APR 1.1 [Deferring these features when 1.0 is rolled out.]
*) Add a new PRNG. Note that the implementation of SHA-256 is a
stop-gap pending snarfing the SHA-1 implementation from apr-util
and upgrading it to do SHA-256. Not yet ready for prime time.
[Ben Laurie]
+
+Changes with APR 1.0
+
+ *) Removed apr_socket_opt_{get|set}(..., APR_SO_TIMEOUT) which
+ was deprecated in favor of apr_socket_timeout_{get|set}().
+
+ *) Change i386 FreeBSD to use the asm routines in apr_atomic.h
+ to overcome issues with the FreeBSD atomic functions return
+ type on i386. [David Reid]
*) Added new versions of the apr_atomic functions for
use with 32-bit ints [Brian Pane]
1.148 +0 -18 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.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- apr_network_io.h 14 Oct 2003 23:47:29 -0000 1.147
+++ apr_network_io.h 20 Nov 2003 17:40:16 -0000 1.148
@@ -103,7 +103,6 @@
#define APR_SO_DEBUG 4 /**< Debug */
#define APR_SO_NONBLOCK 8 /**< Non-blocking IO */
#define APR_SO_REUSEADDR 16 /**< Reuse addresses */
-#define APR_SO_TIMEOUT 32 /**< Timeout */
#define APR_SO_SNDBUF 64 /**< Send buffer */
#define APR_SO_RCVBUF 128 /**< Receive buffer */
#define APR_SO_DISCONNECTED 256 /**< Disconnected */
@@ -728,23 +727,6 @@
APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1,
const apr_sockaddr_t *addr2);
-
-#if APR_FILES_AS_SOCKETS || defined(DOXYGEN)
-
-/**
- * Convert a File type to a socket so that it can be used in a poll
operation.
- * @param newsock the newly created socket which represents a file.
- * @param file the file to mask as a socket.
- * @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);
-
-#endif /* APR_FILES_AS_SOCKETS */
/**
* Given an apr_sockaddr_t and a service name, set the port for the service
1.37 +0 -8 apr/network_io/os2/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/os2/sockopt.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- sockopt.c 16 Oct 2003 10:54:45 -0000 1.36
+++ sockopt.c 20 Nov 2003 17:40:16 -0000 1.37
@@ -120,10 +120,6 @@
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_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;
}
1.102 +27 -33 apr/network_io/unix/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- sendrecv.c 2 Nov 2003 20:51:18 -0000 1.101
+++ sendrecv.c 20 Nov 2003 17:40:16 -0000 1.102
@@ -80,7 +80,7 @@
} 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 @@
*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 @@
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 @@
(*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 @@
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 @@
(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 @@
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 @@
*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 @@
*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 @@
* 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 @@
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 @@
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 @@
}
} 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 @@
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 @@
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 @@
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 @@
/* 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;
1.115 +2 -2 apr/network_io/unix/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- sockets.c 17 Nov 2003 01:41:18 -0000 1.114
+++ sockets.c 20 Nov 2003 17:40:16 -0000 1.115
@@ -271,8 +271,8 @@
/* 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;
1.74 +0 -10 apr/network_io/unix/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- sockopt.c 2 Nov 2003 20:51:18 -0000 1.73
+++ sockopt.c 20 Nov 2003 17:40:16 -0000 1.74
@@ -144,8 +144,6 @@
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 @@
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_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);
}
1.56 +0 -9 apr/network_io/win32/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockopt.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- sockopt.c 2 Nov 2003 20:51:18 -0000 1.55
+++ sockopt.c 20 Nov 2003 17:40:16 -0000 1.56
@@ -133,11 +133,6 @@
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_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;