Skip to content
Permalink
Browse files
[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>
  • Loading branch information
mhubail committed Feb 17, 2021
1 parent 486aac3 commit 334cf2044cd3a27c9c1fe833a3ef13e0edadbdd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
@@ -477,8 +477,7 @@ private void close(SelectionKey key, SocketChannel sc) {
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 @@ private void handleHandshakeCompletion(Boolean handshakeSuccess, ISocketChannel
connectionEstablished(handle, channelKey, socketChannel);
}
} else {
closeHandle(handle);
close(channelKey, socketChannel.getSocketChannel());
}
}
@@ -538,5 +538,12 @@ private void connectionReceived(ISocketChannel channel, SelectionKey channelKey)
handle.setKey(channelKey);
channelKey.attach(handle);
}

private void closeHandle(IPCHandle handle) {
if (handle != null) {
handle.close();
unregisterHandle(handle);
}
}
}
}
@@ -233,8 +233,11 @@ private void handleReadUnderflow() {

private void handleEndOfStreamQuietly() {
try {
engine.closeInbound();
close();
try {
engine.closeInbound();
} finally {
close();
}
} catch (Exception e) {
LOGGER.warn("failed to close socket gracefully", e);
}

0 comments on commit 334cf20

Please sign in to comment.