You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@apache.org on 2003/11/02 21:51:18 UTC
cvs commit: apr/network_io/win32 sockets.c sockopt.c
gstein 2003/11/02 12:51:18
Modified: include/arch/os2 apr_arch_networkio.h
include/arch/unix apr_arch_networkio.h
include/arch/win32 apr_arch_networkio.h
network_io/unix sendrecv.c sockets.c sockopt.c
network_io/win32 sockets.c sockopt.c
Log:
The use of "netmask" to hold options is a bit beyond bogus. That term has
an entirely different meaning in a networking context. Rename the socket
field to "options".
Also simplified the test/set macros to just take a socket.
* include/arch/os2/apr_arch_networkio.h:
* include/arch/unix/apr_arch_networkio.h:
* include/arch/win32/apr_arch_networkio.h:
- perform adjustments as above. change all uses.
Revision Changes Path
1.4 +1 -1 apr/include/arch/os2/apr_arch_networkio.h
Index: apr_arch_networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/os2/apr_arch_networkio.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- apr_arch_networkio.h 8 Jul 2003 12:53:10 -0000 1.3
+++ apr_arch_networkio.h 2 Nov 2003 20:51:18 -0000 1.4
@@ -82,7 +82,7 @@
int local_port_unknown;
int local_interface_unknown;
int remote_addr_unknown;
- apr_int32_t netmask;
+ apr_int32_t options;
apr_int32_t inherit;
sock_userdata_t *userdata;
};
1.5 +6 -5 apr/include/arch/unix/apr_arch_networkio.h
Index: apr_arch_networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/apr_arch_networkio.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- apr_arch_networkio.h 15 Oct 2003 13:34:26 -0000 1.4
+++ apr_arch_networkio.h 2 Nov 2003 20:51:18 -0000 1.5
@@ -149,7 +149,7 @@
int local_port_unknown;
int local_interface_unknown;
int remote_addr_unknown;
- apr_int32_t netmask;
+ apr_int32_t options;
apr_int32_t inherit;
sock_userdata_t *userdata;
};
@@ -158,14 +158,15 @@
int apr_inet_pton(int af, const char *src, void *dst);
void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t);
-#define apr_is_option_set(mask, option) ((mask & option) ==option)
+#define apr_is_option_set(skt, option) \
+ (((skt)->options & (option)) == (option))
-#define apr_set_option(mask, option, on) \
+#define apr_set_option(skt, option, on) \
do { \
if (on) \
- *mask |= option; \
+ (skt)->options |= (option); \
else \
- *mask &= ~option; \
+ (skt)->options &= ~(option); \
} while (0)
#endif /* ! NETWORK_IO_H */
1.3 +6 -4 apr/include/arch/win32/apr_arch_networkio.h
Index: apr_arch_networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/apr_arch_networkio.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- apr_arch_networkio.h 8 Jul 2003 12:53:10 -0000 1.2
+++ apr_arch_networkio.h 2 Nov 2003 20:51:18 -0000 1.3
@@ -78,7 +78,7 @@
int local_port_unknown;
int local_interface_unknown;
int remote_addr_unknown;
- apr_int32_t netmask;
+ apr_int32_t options;
apr_int32_t inherit;
sock_userdata_t *userdata;
};
@@ -98,13 +98,15 @@
int apr_inet_pton(int af, const char *src, void *dst);
void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t);
-#define apr_is_option_set(mask, option) ((mask & option) ==option)
+#define apr_is_option_set(skt, option) \
+ (((skt)->options & (option)) == (option))
+
#define apr_set_option(mask, option, on) \
do { \
if (on) \
- *mask |= option; \
+ *(mask) |= (option); \
else \
- *mask &= ~option; \
+ *(mask) &= ~(option); \
} while (0)
#endif /* ! NETWORK_IO_H */
1.101 +38 -38 apr/network_io/unix/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- sendrecv.c 3 Sep 2003 16:31:47 -0000 1.100
+++ sendrecv.c 2 Nov 2003 20:51:18 -0000 1.101
@@ -70,8 +70,8 @@
{
apr_ssize_t rv;
- if (sock->netmask & APR_INCOMPLETE_WRITE) {
- sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ if (sock->options & APR_INCOMPLETE_WRITE) {
+ sock->options &= ~APR_INCOMPLETE_WRITE;
goto do_select;
}
@@ -80,7 +80,7 @@
} while (rv == -1 && errno == EINTR);
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
- && apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ && apr_is_option_set(sock, APR_SO_TIMEOUT)) {
apr_status_t arv;
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -98,8 +98,8 @@
*len = 0;
return errno;
}
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) && rv < *len) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT) && rv < *len) {
+ sock->options |= APR_INCOMPLETE_WRITE;
}
(*len) = rv;
return APR_SUCCESS;
@@ -110,8 +110,8 @@
apr_ssize_t rv;
apr_status_t arv;
- if (sock->netmask & APR_INCOMPLETE_READ) {
- sock->netmask &= ~APR_INCOMPLETE_READ;
+ if (sock->options & APR_INCOMPLETE_READ) {
+ sock->options &= ~APR_INCOMPLETE_READ;
goto do_select;
}
@@ -120,7 +120,7 @@
} while (rv == -1 && errno == EINTR);
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
@@ -137,8 +137,8 @@
(*len) = 0;
return errno;
}
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) && rv < *len) {
- sock->netmask |= APR_INCOMPLETE_READ;
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT) && rv < *len) {
+ sock->options |= APR_INCOMPLETE_READ;
}
(*len) = rv;
if (rv == 0) {
@@ -160,7 +160,7 @@
} while (rv == -1 && errno == EINTR);
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
- && apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ && apr_is_option_set(sock, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -193,7 +193,7 @@
} while (rv == -1 && errno == EINTR);
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -230,8 +230,8 @@
requested_len += vec[i].iov_len;
}
- if (sock->netmask & APR_INCOMPLETE_WRITE) {
- sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ if (sock->options & APR_INCOMPLETE_WRITE) {
+ sock->options &= ~APR_INCOMPLETE_WRITE;
goto do_select;
}
@@ -240,7 +240,7 @@
} while (rv == -1 && errno == EINTR);
if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
apr_status_t arv;
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -258,9 +258,9 @@
*len = 0;
return errno;
}
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) &&
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT) &&
rv < requested_len) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ sock->options |= APR_INCOMPLETE_WRITE;
}
(*len) = rv;
return APR_SUCCESS;
@@ -326,8 +326,8 @@
}
}
- if (sock->netmask & APR_INCOMPLETE_WRITE) {
- sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ if (sock->options & APR_INCOMPLETE_WRITE) {
+ sock->options &= ~APR_INCOMPLETE_WRITE;
goto do_select;
}
@@ -340,7 +340,7 @@
if (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -375,8 +375,8 @@
* partial byte count; this is a non-blocking socket.
*/
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ sock->options |= APR_INCOMPLETE_WRITE;
}
return arv;
}
@@ -499,9 +499,9 @@
/* FreeBSD can send the headers/footers as part of the system call */
do {
- if (sock->netmask & APR_INCOMPLETE_WRITE) {
+ if (sock->options & APR_INCOMPLETE_WRITE) {
apr_status_t arv;
- sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ sock->options &= ~APR_INCOMPLETE_WRITE;
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -523,8 +523,8 @@
if (rv == -1) {
if (errno == EAGAIN) {
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT)) {
+ sock->options |= APR_INCOMPLETE_WRITE;
}
/* FreeBSD's sendfile can return -1/EAGAIN even if it
* sent bytes. Sanitize the result so we get normal EAGAIN
@@ -563,7 +563,7 @@
}
if (rv == -1 &&
errno == EAGAIN &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -681,7 +681,7 @@
if (rc == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -816,8 +816,8 @@
/* O.K. All set up now. Let's go to town */
- if (sock->netmask & APR_INCOMPLETE_WRITE) {
- sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ if (sock->options & APR_INCOMPLETE_WRITE) {
+ sock->options &= ~APR_INCOMPLETE_WRITE;
goto do_select;
}
@@ -829,7 +829,7 @@
if (rv == -1 &&
(errno == EAGAIN || errno == EWOULDBLOCK) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
do_select:
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
@@ -857,9 +857,9 @@
return errno;
}
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) &&
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT) &&
(parms.bytes_sent < (parms.file_bytes + parms.header_length + parms.trailer_length))) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ sock->options |= APR_INCOMPLETE_WRITE;
}
return APR_SUCCESS;
@@ -940,8 +940,8 @@
/* If the last write couldn't send all the requested data,
* wait for the socket to become writable before proceeding
*/
- if (sock->netmask & APR_INCOMPLETE_WRITE) {
- sock->netmask &= ~APR_INCOMPLETE_WRITE;
+ if (sock->options & APR_INCOMPLETE_WRITE) {
+ sock->options &= ~APR_INCOMPLETE_WRITE;
arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (arv != APR_SUCCESS) {
*len = 0;
@@ -972,7 +972,7 @@
rv = 0;
}
else if (!arv &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) == 1) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT) == 1) {
apr_status_t t = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (t != APR_SUCCESS) {
@@ -993,9 +993,9 @@
/* Update how much we sent */
*len = nbytes;
- if (apr_is_option_set(sock->netmask, APR_SO_TIMEOUT) &&
+ if (apr_is_option_set(sock, APR_SO_TIMEOUT) &&
(*len < requested_len)) {
- sock->netmask |= APR_INCOMPLETE_WRITE;
+ sock->options |= APR_INCOMPLETE_WRITE;
}
return APR_SUCCESS;
}
1.113 +7 -7 apr/network_io/unix/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- sockets.c 15 Oct 2003 20:41:44 -0000 1.112
+++ sockets.c 2 Nov 2003 20:51:18 -0000 1.113
@@ -84,12 +84,12 @@
sock->protocol = protocol;
apr_sockaddr_vars_set(sock->local_addr, family, 0);
apr_sockaddr_vars_set(sock->remote_addr, family, 0);
- sock->netmask = 0;
+ sock->options = 0;
#if defined(BEOS) && !defined(BEOS_BONE)
/* BeOS pre-BONE has TCP_NODELAY on by default and it can't be
* switched off!
*/
- sock->netmask |= APR_TCP_NODELAY;
+ sock->options |= APR_TCP_NODELAY;
#endif
}
@@ -224,13 +224,13 @@
}
#if APR_TCP_NODELAY_INHERITED
- if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) == 1) {
- apr_set_option(&(*new)->netmask, APR_TCP_NODELAY, 1);
+ if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1) {
+ apr_set_option(*new, APR_TCP_NODELAY, 1);
}
#endif /* TCP_NODELAY_INHERITED */
#if APR_O_NONBLOCK_INHERITED
- if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) == 1) {
- apr_set_option(&(*new)->netmask, APR_SO_NONBLOCK, 1);
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) {
+ apr_set_option(*new, APR_SO_NONBLOCK, 1);
}
#endif /* APR_O_NONBLOCK_INHERITED */
@@ -267,7 +267,7 @@
* socket; if called again, we can see EALREADY
*/
if (rc == -1 && (errno == EINPROGRESS || errno == EALREADY) &&
- apr_is_option_set(sock->netmask, APR_SO_TIMEOUT)) {
+ apr_is_option_set(sock, APR_SO_TIMEOUT)) {
rc = apr_wait_for_io_or_timeout(NULL, sock, 0);
if (rc != APR_SUCCESS) {
return rc;
1.73 +34 -34 apr/network_io/unix/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- sockopt.c 14 Oct 2003 23:47:29 -0000 1.72
+++ sockopt.c 2 Nov 2003 20:51:18 -0000 1.73
@@ -123,29 +123,29 @@
* We want to avoid calling fcntl more than necessary on the socket,
*/
if (t >= 0 && sock->timeout < 0) {
- if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != 1) {
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 1) {
if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) {
return stat;
}
- apr_set_option(&sock->netmask, APR_SO_NONBLOCK, 1);
+ apr_set_option(sock, APR_SO_NONBLOCK, 1);
}
}
else if (t < 0 && sock->timeout >= 0) {
- if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != 0) {
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) != 0) {
if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) {
return stat;
}
- apr_set_option(&sock->netmask, APR_SO_NONBLOCK, 0);
+ apr_set_option(sock, APR_SO_NONBLOCK, 0);
}
}
/* must disable the incomplete read support if we disable
* a timeout
*/
if (t <= 0) {
- sock->netmask &= ~APR_INCOMPLETE_READ;
+ sock->options &= ~APR_INCOMPLETE_READ;
}
sock->timeout = t;
- apr_set_option(&sock->netmask, APR_SO_TIMEOUT, t > 0);
+ apr_set_option(sock, APR_SO_TIMEOUT, t > 0);
return APR_SUCCESS;
}
@@ -163,39 +163,39 @@
switch(opt) {
case APR_SO_KEEPALIVE:
#ifdef SO_KEEPALIVE
- if (on != apr_is_option_set(sock->netmask, APR_SO_KEEPALIVE)) {
+ if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask,APR_SO_KEEPALIVE, on);
+ apr_set_option(sock, APR_SO_KEEPALIVE, on);
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_SO_DEBUG:
- if (on != apr_is_option_set(sock->netmask, APR_SO_DEBUG)) {
+ if (on != apr_is_option_set(sock, APR_SO_DEBUG)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_SO_DEBUG, on);
+ apr_set_option(sock, APR_SO_DEBUG, on);
}
break;
case APR_SO_REUSEADDR:
- if (on != apr_is_option_set(sock->netmask, APR_SO_REUSEADDR)) {
+ if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_SO_REUSEADDR, on);
+ apr_set_option(sock, APR_SO_REUSEADDR, on);
}
break;
case APR_SO_SNDBUF:
#ifdef SO_SNDBUF
- if (apr_is_option_set(sock->netmask, APR_SO_SNDBUF) != on) {
+ if (apr_is_option_set(sock, APR_SO_SNDBUF) != on) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_SO_SNDBUF, on);
+ apr_set_option(sock, APR_SO_SNDBUF, on);
}
#else
return APR_ENOTIMPL;
@@ -203,18 +203,18 @@
break;
case APR_SO_RCVBUF:
#ifdef SO_RCVBUF
- if (apr_is_option_set(sock->netmask, APR_SO_RCVBUF) != on) {
+ if (apr_is_option_set(sock, APR_SO_RCVBUF) != on) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_RCVBUF, (void *)&on, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_SO_RCVBUF, on);
+ apr_set_option(sock, APR_SO_RCVBUF, on);
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_SO_NONBLOCK:
- if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != on) {
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) {
if (on) {
if ((rv = sononblock(sock->socketdes)) != APR_SUCCESS)
return rv;
@@ -223,19 +223,19 @@
if ((rv = soblock(sock->socketdes)) != APR_SUCCESS)
return rv;
}
- apr_set_option(&sock->netmask, APR_SO_NONBLOCK, on);
+ apr_set_option(sock, APR_SO_NONBLOCK, on);
}
break;
case APR_SO_LINGER:
#ifdef SO_LINGER
- if (apr_is_option_set(sock->netmask, APR_SO_LINGER) != on) {
+ if (apr_is_option_set(sock, APR_SO_LINGER) != on) {
struct linger li;
li.l_onoff = on;
li.l_linger = APR_MAX_SECS_TO_LINGER;
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_SO_LINGER, on);
+ apr_set_option(sock, APR_SO_LINGER, on);
}
#else
return APR_ENOTIMPL;
@@ -247,7 +247,7 @@
break;
case APR_TCP_NODELAY:
#if defined(TCP_NODELAY)
- if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) != on) {
+ if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) {
int optlevel = IPPROTO_TCP;
int optname = TCP_NODELAY;
@@ -260,7 +260,7 @@
if (setsockopt(sock->socketdes, optlevel, optname, (void *)&on, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_TCP_NODELAY, on);
+ apr_set_option(sock, APR_TCP_NODELAY, on);
}
#else
/* BeOS pre-BONE has TCP_NODELAY set by default.
@@ -277,7 +277,7 @@
break;
case APR_TCP_NOPUSH:
#if APR_TCP_NOPUSH_FLAG
- if (apr_is_option_set(sock->netmask, APR_TCP_NOPUSH) != on) {
+ if (apr_is_option_set(sock, APR_TCP_NOPUSH) != on) {
int optlevel = IPPROTO_TCP;
int optname = TCP_NODELAY;
@@ -289,7 +289,7 @@
#endif
/* OK we're going to change some settings here... */
/* TCP_NODELAY is mutually exclusive, so do we have it set? */
- if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) == 1 && on) {
+ if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1 && on) {
/* If we want to set NOPUSH then if we have the TCP_NODELAY
* flag set we need to switch it off...
*/
@@ -298,25 +298,25 @@
(void*)&tmpflag, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_RESET_NODELAY, 1);
- apr_set_option(&sock->netmask, APR_TCP_NODELAY, 0);
+ apr_set_option(sock, APR_RESET_NODELAY, 1);
+ apr_set_option(sock, APR_TCP_NODELAY, 0);
} else if (on) {
- apr_set_option(&sock->netmask, APR_RESET_NODELAY, 0);
+ apr_set_option(sock, APR_RESET_NODELAY, 0);
}
/* OK, now we can just set the TCP_NOPUSH flag accordingly...*/
if (setsockopt(sock->socketdes, IPPROTO_TCP, APR_TCP_NOPUSH_FLAG,
(void*)&on, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_TCP_NOPUSH, on);
- if (!on && apr_is_option_set(sock->netmask, APR_RESET_NODELAY)) {
+ apr_set_option(sock, APR_TCP_NOPUSH, on);
+ if (!on && apr_is_option_set(sock, APR_RESET_NODELAY)) {
int tmpflag = 1;
if (setsockopt(sock->socketdes, optlevel, optname,
(void*)&tmpflag, sizeof(int)) == -1) {
return errno;
}
- apr_set_option(&sock->netmask, APR_RESET_NODELAY,0);
- apr_set_option(&sock->netmask, APR_TCP_NODELAY, 1);
+ apr_set_option(sock, APR_RESET_NODELAY,0);
+ apr_set_option(sock, APR_TCP_NODELAY, 1);
}
}
#else
@@ -324,12 +324,12 @@
#endif
break;
case APR_INCOMPLETE_READ:
- apr_set_option(&sock->netmask, APR_INCOMPLETE_READ, on);
+ apr_set_option(sock, APR_INCOMPLETE_READ, on);
break;
case APR_IPV6_V6ONLY:
#if APR_HAVE_IPV6 && defined(IPV6_V6ONLY)
/* we don't know the initial setting of this option,
- * so don't check/set sock->netmask since that optimization
+ * so don't check/set sock->options since that optimization
* won't work
*/
if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY,
@@ -364,7 +364,7 @@
*on = (apr_int32_t)sock->timeout;
break;
default:
- *on = apr_is_option_set(sock->netmask, opt);
+ *on = apr_is_option_set(sock, opt);
}
return APR_SUCCESS;
}
1.100 +4 -4 apr/network_io/win32/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- sockets.c 15 Oct 2003 20:41:44 -0000 1.99
+++ sockets.c 2 Nov 2003 20:51:18 -0000 1.100
@@ -292,13 +292,13 @@
}
#if APR_TCP_NODELAY_INHERITED
- if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) == 1) {
- apr_set_option(&(*new)->netmask, APR_TCP_NODELAY, 1);
+ if (apr_is_option_set(sock, APR_TCP_NODELAY) == 1) {
+ apr_set_option(*new, APR_TCP_NODELAY, 1);
}
#endif /* TCP_NODELAY_INHERITED */
#if APR_O_NONBLOCK_INHERITED
- if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) == 1) {
- apr_set_option(&(*new)->netmask, APR_SO_NONBLOCK, 1);
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) {
+ apr_set_option(*new, APR_SO_NONBLOCK, 1);
}
#endif /* APR_O_NONBLOCK_INHERITED */
1.55 +15 -14 apr/network_io/win32/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockopt.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- sockopt.c 14 Oct 2003 23:47:29 -0000 1.54
+++ sockopt.c 2 Nov 2003 20:51:18 -0000 1.55
@@ -139,34 +139,34 @@
return apr_socket_timeout_set(sock, on);
}
case APR_SO_KEEPALIVE:
- if (on != apr_is_option_set(sock->netmask, APR_SO_KEEPALIVE)) {
+ if (on != apr_is_option_set(sock, APR_SO_KEEPALIVE)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE,
(void *)&one, sizeof(int)) == -1) {
return apr_get_netos_error();
}
- apr_set_option(&sock->netmask,APR_SO_KEEPALIVE, on);
+ apr_set_option(sock, APR_SO_KEEPALIVE, on);
}
break;
case APR_SO_DEBUG:
- if (on != apr_is_option_set(sock->netmask, APR_SO_DEBUG)) {
+ if (on != apr_is_option_set(sock, APR_SO_DEBUG)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG,
(void *)&one, sizeof(int)) == -1) {
return apr_get_netos_error();
}
- apr_set_option(&sock->netmask, APR_SO_DEBUG, on);
+ apr_set_option(sock, APR_SO_DEBUG, on);
}
break;
case APR_SO_REUSEADDR:
- if (on != apr_is_option_set(sock->netmask, APR_SO_REUSEADDR)) {
+ if (on != apr_is_option_set(sock, APR_SO_REUSEADDR)) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR,
(void *)&one, sizeof(int)) == -1) {
return apr_get_netos_error();
}
- apr_set_option(&sock->netmask, APR_SO_REUSEADDR, on);
+ apr_set_option(sock, APR_SO_REUSEADDR, on);
}
break;
case APR_SO_NONBLOCK:
- if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != on) {
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) != on) {
if (on) {
if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS)
return stat;
@@ -175,12 +175,12 @@
if ((stat = soblock(sock->socketdes)) != APR_SUCCESS)
return stat;
}
- apr_set_option(&sock->netmask, APR_SO_NONBLOCK, on);
+ apr_set_option(sock, APR_SO_NONBLOCK, on);
}
break;
case APR_SO_LINGER:
{
- if (apr_is_option_set(sock->netmask, APR_SO_LINGER) != on) {
+ if (apr_is_option_set(sock, APR_SO_LINGER) != on) {
struct linger li;
li.l_onoff = on;
li.l_linger = APR_MAX_SECS_TO_LINGER;
@@ -188,12 +188,12 @@
(char *) &li, sizeof(struct linger)) == -1) {
return apr_get_netos_error();
}
- apr_set_option(&sock->netmask, APR_SO_LINGER, on);
+ apr_set_option(sock, APR_SO_LINGER, on);
}
break;
}
case APR_TCP_NODELAY:
- if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) != on) {
+ if (apr_is_option_set(sock, APR_TCP_NODELAY) != on) {
int optlevel = IPPROTO_TCP;
int optname = TCP_NODELAY;
@@ -207,13 +207,13 @@
(void *)&on, sizeof(int)) == -1) {
return apr_get_netos_error();
}
- apr_set_option(&sock->netmask, APR_TCP_NODELAY, on);
+ apr_set_option(sock, APR_TCP_NODELAY, on);
}
break;
case APR_IPV6_V6ONLY:
#if APR_HAVE_IPV6 && defined(IPV6_V6ONLY)
/* we don't know the initial setting of this option,
- * so don't check/set sock->netmask since that optimization
+ * so don't check/set sock->options since that optimization
* won't work
*/
if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY,
@@ -256,7 +256,8 @@
case APR_SO_NONBLOCK:
case APR_SO_LINGER:
default:
- *on = apr_is_option_set(sock->netmask, opt);
+ *on = apr_is_option_set(sock, opt);
+ break;
}
return APR_SUCCESS;
}
Re: cvs commit: apr/network_io/win32 sockets.c sockopt.c
Posted by Greg Stein <gs...@lyra.org>.
On Tue, Nov 04, 2003 at 02:23:59AM +0100, Branko ?ibej wrote:
> gstein@apache.org wrote:
>...
> > Also simplified the test/set macros to just take a socket.
>...
> > #define apr_set_option(mask, option, on) \
> > do { \
> > if (on) \
> > - *mask |= option; \
> > + *(mask) |= (option); \
> > else \
> > - *mask &= ~option; \
> > + *(mask) &= ~(option); \
> > } while (0)
> >
> > #endif /* ! NETWORK_IO_H */
>
> Any particular reason for this macro not being the same as the Unix
> version, except making an evil attack on Win32 buildability? :-)
Gah... dealing with too many copies of too many files... Sorry 'bout that.
As you guessed, there was no particular reason. I just missed it and
couldn't get a test win32 compile done. Thanks for the fix!
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: cvs commit: apr/network_io/win32 sockets.c sockopt.c
Posted by Branko Čibej <br...@xbc.nu>.
gstein@apache.org wrote:
>gstein 2003/11/02 12:51:18
>
> Modified: include/arch/os2 apr_arch_networkio.h
> include/arch/unix apr_arch_networkio.h
> include/arch/win32 apr_arch_networkio.h
> network_io/unix sendrecv.c sockets.c sockopt.c
> network_io/win32 sockets.c sockopt.c
> Log:
> The use of "netmask" to hold options is a bit beyond bogus. That term has
> an entirely different meaning in a networking context. Rename the socket
> field to "options".
>
> Also simplified the test/set macros to just take a socket.
>
> * include/arch/os2/apr_arch_networkio.h:
> * include/arch/unix/apr_arch_networkio.h:
> * include/arch/win32/apr_arch_networkio.h:
> - perform adjustments as above. change all uses.
>
>
[...]
> 1.3 +6 -4 apr/include/arch/win32/apr_arch_networkio.h
>
>
[...]
> @@ -98,13 +98,15 @@
> int apr_inet_pton(int af, const char *src, void *dst);
> void apr_sockaddr_vars_set(apr_sockaddr_t *, int, apr_port_t);
>
> -#define apr_is_option_set(mask, option) ((mask & option) ==option)
> +#define apr_is_option_set(skt, option) \
> + (((skt)->options & (option)) == (option))
> +
> #define apr_set_option(mask, option, on) \
> do { \
> if (on) \
> - *mask |= option; \
> + *(mask) |= (option); \
> else \
> - *mask &= ~option; \
> + *(mask) &= ~(option); \
> } while (0)
>
> #endif /* ! NETWORK_IO_H */
>
>
Any particular reason for this macro not being the same as the Unix
version, except making an evil attack on Win32 buildability? :-)
--
Brane Čibej <br...@xbc.nu> http://www.xbc.nu/brane/