wy96f commented on issue #2843: ARTEMIS-2496 Revert catch up with zero-copy, as it's causing issues i… URL: https://github.com/apache/activemq-artemis/pull/2843#issuecomment-533027655 @clebertsuconic @franz1981 Hi, I didn't use wildfly/xnio. Will xnio use a HttpConnection which implements Connection like InVMConnection/NettyConnection? ``` if (connection != null && connection.getTransportConnection() instanceof NettyConnection) { bufferSize -= dataSize; isNetty = true; } buffer = createPacket(connection, bufferSize); encodeHeader(buffer); encodeRest(buffer, connection); if (!isNetty) { if (buffer.byteBuf() != null && buffer.byteBuf().nioBufferCount() == 1 && buffer.byteBuf().isDirect()) { final ByteBuffer byteBuffer = buffer.byteBuf().internalNioBuffer(buffer.writerIndex(), buffer.writableBytes()); readFile(byteBuffer); } else { final ByteBuf byteBuffer = PooledByteBufAllocator.DEFAULT.directBuffer(buffer.writableBytes(), buffer.writableBytes()); try { final ByteBuffer nioBuffer = byteBuffer.internalNioBuffer(0, buffer.writableBytes()); final int readBytes = readFile(nioBuffer); if (readBytes > 0) { //still use byteBuf to copy data buffer.writeBytes(byteBuffer, 0, readBytes); } } finally { byteBuffer.release(); } } buffer.writerIndex(buffer.capacity()); } encodeSize(buffer, encodedSize); return buffer; ``` If not NettyConnection, file data will be read into buffer. Then in ChannelImpl::send ``` connection.getTransportConnection().write(buffer); connection.getTransportConnection().write(raf, fileChannel, offset, dataSize, callback == null ? null : (ChannelFutureListener) future -> callback.done(future == null || future.isSuccess())); ``` Both buffer and file will be written. For InVMConnection, actually no file data is transferred: ``` @Override public void write(RandomAccessFile raf, FileChannel fileChannel, long offset, int dataSize, final ChannelFutureListener futureListener) { if (futureListener == null) { return; } try { executor.execute(() -> { try { futureListener.operationComplete(null); } catch (Exception e) { throw new IllegalStateException(e); } }); } catch (RejectedExecutionException e) { } } ``` But if xnio implements a connection and transfers file data one more time in file send method, the mechanism is broken. Not sure if it is caused by this?
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services