[#1475] Correctly handle writes with empty MessageList in SslHandler
This commit is contained in:
parent
ad73dce7a1
commit
e06fcdbc6a
@ -392,6 +392,13 @@ public class SslHandler
|
|||||||
ctx.write(msgs, promise);
|
ctx.write(msgs, promise);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if (msgs.isEmpty()) {
|
||||||
|
// if the MessageList is empty we need to add an empty buffer as pending write as otherwise
|
||||||
|
// the promise will never be notified.
|
||||||
|
// See https://github.com/netty/netty/issues/1475
|
||||||
|
pendingUnencryptedWrites.add(new PendingWrite(Unpooled.EMPTY_BUFFER, promise));
|
||||||
|
} else {
|
||||||
for (int i = 0; i < msgs.size(); i++) {
|
for (int i = 0; i < msgs.size(); i++) {
|
||||||
ByteBuf msg = (ByteBuf) msgs.get(i);
|
ByteBuf msg = (ByteBuf) msgs.get(i);
|
||||||
ChannelPromise cp;
|
ChannelPromise cp;
|
||||||
@ -402,7 +409,11 @@ public class SslHandler
|
|||||||
}
|
}
|
||||||
pendingUnencryptedWrites.add(new PendingWrite(msg, cp));
|
pendingUnencryptedWrites.add(new PendingWrite(msg, cp));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
flush0(ctx);
|
flush0(ctx);
|
||||||
|
} finally {
|
||||||
|
msgs.recycle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flush0(ChannelHandlerContext ctx) throws SSLException {
|
private void flush0(ChannelHandlerContext ctx) throws SSLException {
|
||||||
|
@ -111,10 +111,7 @@ public class SocketSslEchoTest extends AbstractSocketTest {
|
|||||||
for (int i = FIRST_MESSAGE_SIZE; i < data.length;) {
|
for (int i = FIRST_MESSAGE_SIZE; i < data.length;) {
|
||||||
int length = Math.min(random.nextInt(1024 * 64), data.length - i);
|
int length = Math.min(random.nextInt(1024 * 64), data.length - i);
|
||||||
ChannelFuture future = cc.write(Unpooled.wrappedBuffer(data, i, length));
|
ChannelFuture future = cc.write(Unpooled.wrappedBuffer(data, i, length));
|
||||||
// TODO: Remove me as it seems like ChunkWriteHandler has a bug which let it hang here
|
|
||||||
if (!chunkWriteHandler) {
|
|
||||||
future.sync();
|
future.sync();
|
||||||
}
|
|
||||||
i += length;
|
i += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user