Hey there gang. I'm using the apr_socket_timeout_set() call to set a timeout on a socket. Then I establish my connection and turn off the timeout by calling the same function with an interval of -1. Now this works great and I love it since it saves me from all the other headaches involved with setting timeouts on calls to connect. Now, APR makes the socket non blocking in order to do this, which is fine and makes sense. Now when I turn off the timeout, it fails to clear the flag from the socket's file descriptor because the code never sets the APR_SO_NONBLOCK flag in the APR socket's netmask. For example, the problem never occurs if I set the socket to non blocking myself via a call to apr_socket_set_opt and then set my timeout, because now when I turn off the timeouts, it sees that APR_SO_NONBLOCK is set and turns it off. It seems to me that apr_socket_timeout_set should set the APR_SO_NONBLOCK also, since it is making the socket nonblocking. . . I've included a patch that does this although I'm not sure this is how the majority would prefer I do it, just the easiest way (ahem, 2 lines) and solves my problem.

Does this make sense? Is this the intended behavior?

jacob lewallen
[EMAIL PROTECTED]
Index: sockopt.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sockopt.c,v
retrieving revision 1.67
diff -u -u -r1.67 sockopt.c
--- sockopt.c   24 Feb 2003 23:13:29 -0000      1.67
+++ sockopt.c   11 Mar 2003 23:20:53 -0000
@@ -126,6 +126,7 @@
             if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) {
                 return stat;
             }
+            apr_set_option(&sock->netmask, APR_SO_NONBLOCK, 1);
         }
     } 
     else if (t < 0 && sock->timeout >= 0) {
@@ -133,6 +134,7 @@
             if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) { 
                 return stat; 
             }
+            apr_set_option(&sock->netmask, APR_SO_NONBLOCK, 0);
         } 
     }
     /* must disable the incomplete read support if we change to a

Reply via email to