[NO ISSUE][NET] Ensure handle is closed on ssl handshake failure
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- When an ssl handshake fails, close the handle to notify
any waiting threads on the handle to connect.
- Ensure close is called on ssl socket.
Change-Id: I2bd98065f606ad43121b7f06a729fa336f1a7360
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10005
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Hussain Towaileb <hussainht@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCConnectionManager.java b/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCConnectionManager.java
index eaae8e7..5834f26 100644
--- a/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCConnectionManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/impl/IPCConnectionManager.java
@@ -477,8 +477,7 @@
final Object attachment = key.attachment();
if (attachment != null) {
final IPCHandle handle = (IPCHandle) attachment;
- handle.close();
- unregisterHandle(handle);
+ closeHandle(handle);
}
key.cancel();
}
@@ -527,6 +526,7 @@
connectionEstablished(handle, channelKey, socketChannel);
}
} else {
+ closeHandle(handle);
close(channelKey, socketChannel.getSocketChannel());
}
}
@@ -538,5 +538,12 @@
handle.setKey(channelKey);
channelKey.attach(handle);
}
+
+ private void closeHandle(IPCHandle handle) {
+ if (handle != null) {
+ handle.close();
+ unregisterHandle(handle);
+ }
+ }
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/sockets/SslSocketChannel.java b/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/sockets/SslSocketChannel.java
index 74deefe..f9bf5c7 100644
--- a/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/sockets/SslSocketChannel.java
+++ b/hyracks-fullstack/hyracks/hyracks-ipc/src/main/java/org/apache/hyracks/ipc/sockets/SslSocketChannel.java
@@ -233,8 +233,11 @@
private void handleEndOfStreamQuietly() {
try {
- engine.closeInbound();
- close();
+ try {
+ engine.closeInbound();
+ } finally {
+ close();
+ }
} catch (Exception e) {
LOGGER.warn("failed to close socket gracefully", e);
}