mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8274524: SSLSocket.close() hangs if it is called during the ssl handshake
Reviewed-by: xuelei
This commit is contained in:
parent
aa918a6ec4
commit
58dae60da0
2 changed files with 151 additions and 0 deletions
|
@ -107,6 +107,11 @@ public final class SSLSocketImpl
|
|||
private static final boolean trustNameService =
|
||||
Utilities.getBooleanProperty("jdk.tls.trustNameService", false);
|
||||
|
||||
/*
|
||||
* Default timeout to skip bytes from the open socket
|
||||
*/
|
||||
private static final int DEFAULT_SKIP_TIMEOUT = 1;
|
||||
|
||||
/**
|
||||
* Package-private constructor used to instantiate an unconnected
|
||||
* socket.
|
||||
|
@ -1781,9 +1786,21 @@ public final class SSLSocketImpl
|
|||
if (conContext.inputRecord instanceof
|
||||
SSLSocketInputRecord inputRecord && isConnected) {
|
||||
if (appInput.readLock.tryLock()) {
|
||||
int soTimeout = getSoTimeout();
|
||||
try {
|
||||
// deplete could hang on the skip operation
|
||||
// in case of infinite socket read timeout.
|
||||
// Change read timeout to avoid deadlock.
|
||||
// This workaround could be replaced later
|
||||
// with the right synchronization
|
||||
if (soTimeout == 0)
|
||||
setSoTimeout(DEFAULT_SKIP_TIMEOUT);
|
||||
inputRecord.deplete(false);
|
||||
} catch (java.net.SocketTimeoutException stEx) {
|
||||
// skip timeout exception during deplete
|
||||
} finally {
|
||||
if (soTimeout == 0)
|
||||
setSoTimeout(soTimeout);
|
||||
appInput.readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue