From 27311c0eb08f609a5666f2ff96ebbcdd8e99d0ca Mon Sep 17 00:00:00 2001 From: Flavia Rainone Date: Tue, 10 Sep 2019 05:22:23 -0300 Subject: [PATCH] xnio#14 At AbstractXnioSocketChannel.doWrite, skip loop if there is a non BytBuf message to handle it properly --- .../netty/transport/AbstractXnioSocketChannel.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/xnio/netty/transport/AbstractXnioSocketChannel.java b/src/main/java/org/xnio/netty/transport/AbstractXnioSocketChannel.java index 97e82fe..2c78b93 100644 --- a/src/main/java/org/xnio/netty/transport/AbstractXnioSocketChannel.java +++ b/src/main/java/org/xnio/netty/transport/AbstractXnioSocketChannel.java @@ -178,6 +178,7 @@ protected void doWrite(ChannelOutboundBuffer in) throws Exception { } } + boolean byteBuffersOnly = true; if (done) { // Release all buffers for (int i = msgCount; i > 0; i --) { @@ -194,6 +195,10 @@ protected void doWrite(ChannelOutboundBuffer in) throws Exception { // Release the fully written buffers and update the indexes of the partially written buffer. for (int i = msgCount; i > 0; i --) { + if (in.current() != null && ! (in.current() instanceof ByteBuf)) { + byteBuffersOnly = false; + break; + } final ByteBuf buf = (ByteBuf) in.current(); final int readerIndex = buf.readerIndex(); final int readableBytes = buf.writerIndex() - readerIndex; @@ -212,14 +217,13 @@ protected void doWrite(ChannelOutboundBuffer in) throws Exception { break; } } - incompleteWrite(setOpWrite); break; } - continue; + if (byteBuffersOnly) + continue; } } - Object msg = in.current(); if (msg == null) { // Wrote all messages.