HTTPCORE-644: non-blocking TLSv1.3 connections can end up in an infinite event spin when closed concurrently by the local and the remote endpoints
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
index c135ea4..806794c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
@@ -435,11 +435,15 @@ private void updateEventMask() {
if (this.endOfStream && !this.inPlain.hasData()) {
newMask = newMask & ~EventMask.READ;
+ } else if (this.status == Status.CLOSING) {
+ newMask = newMask | EventMask.READ;
}
// Do we have encrypted data ready to be sent?
if (this.outEncrypted.hasData()) {
newMask = newMask | EventMask.WRITE;
+ } else if (this.sslEngine.isOutboundDone()) {
+ newMask = newMask & ~EventMask.WRITE;
}
// Update the mask if necessary