7096436: (sc) SocketChannel.connect fails on Windows 8 when channel configured non-blocking
Set localAddress only when connection is established Reviewed-by: alanb
This commit is contained in:
parent
34aa937e99
commit
2c13671808
@ -629,17 +629,6 @@ class SocketChannelImpl
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (stateLock) {
|
|
||||||
if (isOpen() && (localAddress == null) ||
|
|
||||||
((InetSocketAddress)localAddress)
|
|
||||||
.getAddress().isAnyLocalAddress())
|
|
||||||
{
|
|
||||||
// Socket was not bound before connecting or
|
|
||||||
// Socket was bound with an "anyLocalAddress"
|
|
||||||
localAddress = Net.localAddress(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
readerCleanup();
|
readerCleanup();
|
||||||
end((n > 0) || (n == IOStatus.UNAVAILABLE));
|
end((n > 0) || (n == IOStatus.UNAVAILABLE));
|
||||||
@ -659,6 +648,8 @@ class SocketChannelImpl
|
|||||||
// Connection succeeded; disallow further
|
// Connection succeeded; disallow further
|
||||||
// invocation
|
// invocation
|
||||||
state = ST_CONNECTED;
|
state = ST_CONNECTED;
|
||||||
|
if (isOpen())
|
||||||
|
localAddress = Net.localAddress(fd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// If nonblocking and no exception then connection
|
// If nonblocking and no exception then connection
|
||||||
@ -747,6 +738,8 @@ class SocketChannelImpl
|
|||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
synchronized (stateLock) {
|
synchronized (stateLock) {
|
||||||
state = ST_CONNECTED;
|
state = ST_CONNECTED;
|
||||||
|
if (isOpen())
|
||||||
|
localAddress = Net.localAddress(fd);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user