This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: fix non-blocking socket connect


For non-blocking socket connects, we throw a timeout exception before we
have a chance to record the target host address and port in the
implementation socket.  Currently, when select finally notifies us that
the connection was successful, our implementation socket has no idea who
it connected with.  We need to record this information while we still
have it, before the failed connect.  SocketImpl is still smart enough to
return null and 0 for these values when the socket is not connected
(after our timed-out connect() and prior to the actual connection).

Ok for HEAD and 4.1?

GNU Classpath will require an equivalent patch to the networking JNI
code.



2005-12-26  Anthony Green  <green@redhat.com>

	* gnu/java/net/natPlainSocketImplPosix.cc (connect): Record
	address and port before attempting anything.


--- gnu/java/net/natPlainSocketImplPosix.cc~	2005-11-16 04:03:17.000000000 -0500
+++ gnu/java/net/natPlainSocketImplPosix.cc	2005-12-26 19:34:46.000000000 -0500
@@ -141,7 +141,10 @@
   ::java::net::InetSocketAddress *tmp = (::java::net::InetSocketAddress*) addr;
   ::java::net::InetAddress *host = tmp->getAddress();
   jint rport = tmp->getPort();
-	
+
+  address = host;
+  port = rport;
+
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
   jbyteArray haddress = host->addr;
@@ -197,9 +200,6 @@
         goto error;
     }
 
-  address = host;
-  port = rport;
-
   // A bind may not have been done on this socket; if so, set localport now.
   if (localport == 0)
     {



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]