Skip empty buffers and not pass these to BIO_write

Motivation:

When BIO_write is called with an empty buffer it will return 0 for which we call ERR_clear_error(). This is not neccessary as we should just skip these buffers. This eliminates a lot of overhead.

Modifications:

Skip empty src buffers when call unwrap(...).

Result:

Less overhead for unwrap(...) when called with empty buffers.
This commit is contained in:
Norman Maurer 2015-07-03 20:43:13 +02:00
parent 61b9da470a
commit a9d2b5cef0

View File

@ -652,6 +652,12 @@ public final class OpenSslEngine extends SSLEngine {
do {
ByteBuffer src = srcs[srcsOffset];
int remaining = src.remaining();
if (remaining == 0) {
// We must skip empty buffers as BIO_write will return 0 if asked to write something
// with length 0.
srcsOffset ++;
continue;
}
int written = writeEncryptedData(src);
if (written > 0) {
bytesConsumed += written;