harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r829056 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
Date Fri, 23 Oct 2009 13:32:07 GMT
Author: odeakin
Date: Fri Oct 23 13:32:06 2009
New Revision: 829056

URL: http://svn.apache.org/viewvc?rev=829056&view=rev
Log:
The port library hysock_connect_with_timeout() function only takes an unsigned 32bit value
as a timeout (with a maximum value of 100ms), so passing -1 here for a blocking connect makes
no sense. Instead poll the call with 100ms timeouts for a while before throwing a ConnectException
to indicate failure.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c?rev=829056&r1=829055&r2=829056&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
Fri Oct 23 13:32:06 2009
@@ -588,10 +588,27 @@
                                     HY_PORT_SOCKET_STEP_START, &context);
       break;
     case SOCKET_CONNECT_STEP_CHECK:
-
-      result =
-        hysock_connect_with_timeout(socketP, &sockaddrP, timeout,
+      if (timeout == -1) {
+            /* Blocking connect, so loop for a reasonable amount of time, then
+             * throw a ConnectException if we still fail to connect. This matches
+             * the behaviour of the RI with a similar timeout.
+             */
+            int i = 0;
+            for (; i<1000; i++) {
+                result = hysock_connect_with_timeout(socketP, &sockaddrP, 100,
                                     HY_PORT_SOCKET_STEP_CHECK, &context);
+                if (0 == result) {
+                    break;
+                }
+            }
+            if (0 != result) {
+                throwJavaNetConnectException(env, result);
+                return result;
+            }
+        } else {
+            result = hysock_connect_with_timeout(socketP, &sockaddrP, timeout,
+                                    HY_PORT_SOCKET_STEP_CHECK, &context);
+        }
       break;
     }
 



Mime
View raw message