aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java
diff options
context:
space:
mode:
authorAnthony Green <green@redhat.com>2005-12-28 18:29:10 +0000
committerAnthony Green <green@gcc.gnu.org>2005-12-28 18:29:10 +0000
commit44fae9caaeb326cdb6b034b15fbb1c9412317275 (patch)
treedc4c778776ddd1e0534e7b2056e0444e8cc0ac08 /libjava/gnu/java
parent5c3bb9eb9ed5f92b376c048460d515416fad962b (diff)
downloadgcc-44fae9caaeb326cdb6b034b15fbb1c9412317275.zip
gcc-44fae9caaeb326cdb6b034b15fbb1c9412317275.tar.gz
gcc-44fae9caaeb326cdb6b034b15fbb1c9412317275.tar.bz2
natPlainSocketImplPosix.cc (connect): Record address and port before attempting anything.
2005-12-28 Anthony Green <green@redhat.com> * gnu/java/net/natPlainSocketImplPosix.cc (connect): Record address and port before attempting anything. From-SVN: r109116
Diffstat (limited to 'libjava/gnu/java')
-rw-r--r--libjava/gnu/java/net/natPlainSocketImplPosix.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/libjava/gnu/java/net/natPlainSocketImplPosix.cc b/libjava/gnu/java/net/natPlainSocketImplPosix.cc
index 643f4e4..be9437c 100644
--- a/libjava/gnu/java/net/natPlainSocketImplPosix.cc
+++ b/libjava/gnu/java/net/natPlainSocketImplPosix.cc
@@ -142,6 +142,15 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr,
::java::net::InetAddress *host = tmp->getAddress();
jint rport = tmp->getPort();
+ // Set the SocketImpl's address and port fields before we try to
+ // connect. Note that the fact that these are set doesn't imply
+ // that we're actually connected to anything. We need to record
+ // this data before we attempt the connect, since non-blocking
+ // SocketChannels will use this and almost certainly throw timeout
+ // exceptions.
+ address = host;
+ port = rport;
+
union SockAddr u;
socklen_t addrlen = sizeof(u);
jbyteArray haddress = host->addr;
@@ -197,9 +206,6 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr,
goto error;
}
- address = host;
- port = rport;
-
// A bind may not have been done on this socket; if so, set localport now.
if (localport == 0)
{