Skip to content

Commit

Permalink
Issue #4217 - SslConnection DecryptedEndpoint flush eternal busy loop
Browse files Browse the repository at this point in the history
+ Small cleanup of duplicate if statements

Signed-off-by: Joakim Erdfelt <[email protected]>
  • Loading branch information
joakime committed Oct 25, 2019
1 parent e665c8f commit 93a5ff0
Showing 1 changed file with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -692,47 +692,29 @@ else if (_decryptedInput == null)
_underFlown = unwrapResultStatus == Status.BUFFER_UNDERFLOW ||
unwrapResultStatus == Status.OK && unwrapResult.bytesConsumed() == 0 && unwrapResult.bytesProduced() == 0;

if (_underFlown)
{
if (net_filled < 0 && _sslEngine.getUseClientMode())
closeInbound();
if (net_filled <= 0)
return net_filled;
}

switch (unwrapResultStatus)
{
case CLOSED:
{
switch (handshakeStatus)
{
case NOT_HANDSHAKING:
{
// We were not handshaking, so just tell the app we are closed
return -1;
}
case NEED_TASK:
{
_sslEngine.getDelegatedTask().run();
continue;
}
case NEED_WRAP:
{
// We need to send some handshake data (probably the close handshake).
// We return -1 so that the application can drive the close by flushing
// or shutting down the output.
return -1;
}
case NEED_UNWRAP:
{
// We expected to read more, but we got closed.
// Return -1 to indicate to the application to drive the close.
return -1;
}
default:
{
throw new IllegalStateException();
}
}
}
case BUFFER_OVERFLOW:
Expand Down Expand Up @@ -762,8 +744,7 @@ else if (_decryptedInput == null)
catch (SSLException closeFailure)
{
Throwable handshakeFailure = new SSLHandshakeException("Abruptly closed by peer");
if (closeFailure != null)
handshakeFailure.initCause(closeFailure);
handshakeFailure.initCause(closeFailure);
throw handshakeFailure;
}

Expand Down

0 comments on commit 93a5ff0

Please sign in to comment.