Fix #6082 Reduce SSL buffer compaction (#6083)

Fix #6082 Reduce SSL buffer compaction
Only compact when buffer is underflown.  Note that BufferUtil will also do a cheap "compact" when flipping empty buffers.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2021-03-24 05:04:27 +08:00 committed by GitHub
parent 039c7386d0
commit 96f707f74b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -654,7 +654,6 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr
else
{
appIn = _decryptedInput;
BufferUtil.compact(_encryptedInput);
}
// Let's try reading some encrypted data... even if we have some already.
@ -712,12 +711,18 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr
return filled = -1;
case BUFFER_UNDERFLOW:
// Continue if we can compact?
if (BufferUtil.compact(_encryptedInput))
continue;
// Are we out of space?
if (BufferUtil.space(_encryptedInput) == 0)
{
BufferUtil.clear(_encryptedInput);
throw new SSLHandshakeException("Encrypted buffer max length exceeded");
}
// if we just filled some
if (netFilled > 0)
continue; // try filling some more