Skip to content

Commit

Permalink
Fix #6082 Reduce SSL buffer compaction (#6083)
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 96f707f)
  • Loading branch information
gregw authored and sbordet committed Apr 7, 2021
1 parent 941d7fb commit 58538c9
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ public int fill(ByteBuffer buffer) throws IOException
else
{
appIn = _decryptedInput;
BufferUtil.compact(_encryptedInput);
}

// Let's try reading some encrypted data... even if we have some already.
Expand Down Expand Up @@ -729,12 +728,18 @@ public int fill(ByteBuffer buffer) throws IOException
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

Expand Down

0 comments on commit 58538c9

Please sign in to comment.