Skip to content

Commit 2682073

Browse files
committed
[refactor] attempt a flush on SSLSocket#close
1 parent 2027581 commit 2682073

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,7 @@ private boolean flushData(boolean blocking) throws IOException {
615615
netData.position(netData.limit());
616616
throw ioe;
617617
}
618-
if ( netData.hasRemaining() ) {
619-
return true;
620-
}
621-
return false;
618+
return netData.hasRemaining();
622619
}
623620

624621
private int writeToChannel(ByteBuffer buffer, boolean blocking) throws IOException {
@@ -755,11 +752,15 @@ private void closeInbound() {
755752
}
756753

757754
private void doShutdown() throws IOException {
758-
if ( engine.isOutboundDone() ) return;
755+
if (engine.isOutboundDone()) return;
759756

757+
if (flushData(false)) {
758+
debug(getRuntime(), "SSLSocket.doShutdown data in the data buffer - can't send close");
759+
return;
760+
}
760761
netData.clear();
761762
try {
762-
engine.wrap(dummy, netData);
763+
engine.wrap(dummy, netData); // send close (after sslEngine.closeOutbound)
763764
}
764765
catch (SSLException e) {
765766
debug(getRuntime(), "SSLSocket.doShutdown", e);

0 commit comments

Comments
 (0)