[#1475] Correctly handle writes with empty MessageList in SslHandler
This commit is contained in:
parent
ad73dce7a1
commit
e06fcdbc6a
|
@ -392,17 +392,28 @@ public class SslHandler
|
||||||
ctx.write(msgs, promise);
|
ctx.write(msgs, promise);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < msgs.size(); i++) {
|
try {
|
||||||
ByteBuf msg = (ByteBuf) msgs.get(i);
|
if (msgs.isEmpty()) {
|
||||||
ChannelPromise cp;
|
// if the MessageList is empty we need to add an empty buffer as pending write as otherwise
|
||||||
if (i + 1 == msgs.size()) {
|
// the promise will never be notified.
|
||||||
cp = promise;
|
// See https://github.com/netty/netty/issues/1475
|
||||||
|
pendingUnencryptedWrites.add(new PendingWrite(Unpooled.EMPTY_BUFFER, promise));
|
||||||
} else {
|
} else {
|
||||||
cp = ctx.newPromise();
|
for (int i = 0; i < msgs.size(); i++) {
|
||||||
|
ByteBuf msg = (ByteBuf) msgs.get(i);
|
||||||
|
ChannelPromise cp;
|
||||||
|
if (i + 1 == msgs.size()) {
|
||||||
|
cp = promise;
|
||||||
|
} else {
|
||||||
|
cp = ctx.newPromise();
|
||||||
|
}
|
||||||
|
pendingUnencryptedWrites.add(new PendingWrite(msg, cp));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pendingUnencryptedWrites.add(new PendingWrite(msg, cp));
|
flush0(ctx);
|
||||||
|
} finally {
|
||||||
|
msgs.recycle();
|
||||||
}
|
}
|
||||||
flush0(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
future.sync();
|
||||||
if (!chunkWriteHandler) {
|
|
||||||
future.sync();
|
|
||||||
}
|
|
||||||
i += length;
|
i += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user