apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r745813 - /apr/apr/trunk/file_io/win32/pipe.c
Date Thu, 19 Feb 2009 10:57:12 GMT
Author: mturk
Date: Thu Feb 19 10:57:12 2009
New Revision: 745813

URL: http://svn.apache.org/viewvc?rev=745813&view=rev
Log:
On busy systems the accept can be delayed, so use the select and wait untill fully connected

Modified:
    apr/apr/trunk/file_io/win32/pipe.c

Modified: apr/apr/trunk/file_io/win32/pipe.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/pipe.c?rev=745813&r1=745812&r2=745813&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/pipe.c (original)
+++ apr/apr/trunk/file_io/win32/pipe.c Thu Feb 19 10:57:12 2009
@@ -229,8 +229,9 @@
 static apr_status_t create_socket_pipe(SOCKET *rd, SOCKET *wr)
 {
     static int id = 0;
-
+    FD_SET rs;    
     SOCKET ls;
+    struct timeval socktm;
     struct sockaddr_in pa;
     struct sockaddr_in la;
     struct sockaddr_in ca;
@@ -290,10 +291,27 @@
         goto cleanup;
     }
     for (;;) {
+        int ns;
         /* Listening socket is nonblocking by now.
-         * The accept must create the socket
-         * immediatelly because we connected already.
+         * The accept should create the socket
+         * immediatelly because we are connected already.
+         * However on buys systems this can take a while
+         * until winsock gets a chance to handle the events.
          */
+        FD_ZERO(&rs);
+        FD_SET(ls, &rs);
+
+        socktm.tv_sec  = 1;
+        socktm.tv_usec = 0;
+        if ((ns = select(0, &rs, NULL, NULL, &socktm)) == SOCKET_ERROR) {
+            /* Accept still not signaled */
+            Sleep(100);
+            continue;
+        }
+        if (ns == 0) {
+            /* No connections in the last second */
+            continue;
+        }
         if ((*rd = accept(ls, (SOCKADDR *)&ca, &lc)) == INVALID_SOCKET) {
             rv =  apr_get_netos_error();
             goto cleanup;



Mime
View raw message