8236464: SO_LINGER option is ignored by SSLSocket in JDK 11

Reviewed-by: ascarpino
This commit is contained in:
Xue-Lei Andrew Fan 2020-04-24 13:30:47 -07:00
parent 88f3861cb7
commit bfcb340606
2 changed files with 42 additions and 37 deletions

View file

@ -619,6 +619,15 @@ public final class SSLSocketImpl
}
}
// Deliver the user_canceled alert and the close notify alert.
closeNotify(useUserCanceled);
if (!isInputShutdown()) {
bruteForceCloseInput(hasCloseReceipt);
}
}
void closeNotify(boolean useUserCanceled) throws IOException {
// Need a lock here so that the user_canceled alert and the
// close_notify alert can be delivered together.
int linger = getSoLinger();
@ -633,7 +642,7 @@ public final class SSLSocketImpl
conContext.outputRecord.recordLock.tryLock(
linger, TimeUnit.SECONDS)) {
try {
handleClosedNotifyAlert(useUserCanceled);
deliverClosedNotify(useUserCanceled);
} finally {
conContext.outputRecord.recordLock.unlock();
}
@ -687,18 +696,14 @@ public final class SSLSocketImpl
} else {
conContext.outputRecord.recordLock.lock();
try {
handleClosedNotifyAlert(useUserCanceled);
deliverClosedNotify(useUserCanceled);
} finally {
conContext.outputRecord.recordLock.unlock();
}
}
if (!isInputShutdown()) {
bruteForceCloseInput(hasCloseReceipt);
}
}
private void handleClosedNotifyAlert(
private void deliverClosedNotify(
boolean useUserCanceled) throws IOException {
try {
// send a user_canceled alert if needed.