jerenkrantz 02/05/17 11:10:52
Modified: network_io/unix sockopt.c
Log:
This particular code fragment gets an award for obfuscated code to save a
few cycles. Add a description in plain english so we don't have to waste
*our* cycles figuring out what this optimization is doing. (Every time I
come back to this section, I get confused and the old comment isn't helpful.)
Revision Changes Path
1.52 +6 -1 apr/network_io/unix/sockopt.c
Index: sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- sockopt.c 17 May 2002 17:54:12 -0000 1.51
+++ sockopt.c 17 May 2002 18:10:52 -0000 1.52
@@ -188,7 +188,12 @@
#endif
}
if (opt & APR_SO_TIMEOUT) {
- /* don't do the fcntl foo more than needed */
+ /* If our timeout is positive or zero and our last timeout was
+ * negative, then we need to ensure that we are non-blocking.
+ * Conversely, if our timeout is negative and we had a positive
+ * or zero timeout, we must make sure our socket is blocking.
+ * We want to avoid calling fcntl more than necessary on the socket,
+ */
if (on >= 0 && sock->timeout < 0){
if (apr_is_option_set(sock->netmask, APR_SO_NONBLOCK) != 1){
if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS){