Made sure flushPendingEncryptedWrites are called only when necessary

This commit is contained in:
Trustin Lee 2008-09-05 01:58:35 +00:00
parent ab4d7f7660
commit 27cc323dce

View File

@ -402,6 +402,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
ChannelBuffer msg; ChannelBuffer msg;
ByteBuffer outNetBuf = bufferPool.acquire(); ByteBuffer outNetBuf = bufferPool.acquire();
boolean success = true; boolean success = true;
boolean offered = false;
try { try {
loop: loop:
for (;;) { for (;;) {
@ -446,6 +447,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
pendingEncryptedWrites.offer(encryptedWrite); pendingEncryptedWrites.offer(encryptedWrite);
} }
} }
offered = true;
} else { } else {
switch (result.getHandshakeStatus()) { switch (result.getHandshakeStatus()) {
case NEED_WRAP: case NEED_WRAP:
@ -479,7 +481,9 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
} finally { } finally {
bufferPool.release(outNetBuf); bufferPool.release(outNetBuf);
flushPendingEncryptedWrites(context); if (offered) {
flushPendingEncryptedWrites(context);
}
if (!success) { if (!success) {
// Mark all remaining pending writes as failure if anything // Mark all remaining pending writes as failure if anything