gemmellr commented on a change in pull request #3711:
URL: https://github.com/apache/activemq-artemis/pull/3711#discussion_r701834819
##########
File path:
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
##########
@@ -584,56 +583,45 @@ void deliver() {
deliveryAnnotationsToEncode = null;
}
- LargeBodyReader context = message.getLargeBodyReader();
try {
- context.open();
- try {
+ final ByteBuf frameBuffer =
PooledByteBufAllocator.DEFAULT.directBuffer(frameSize, frameSize);
+ final NettyReadable frameView = new NettyReadable(frameBuffer);
+ try (LargeBodyReader context = message.getLargeBodyReader()) {
+ context.open();
context.position(position);
long bodySize = context.getSize();
+ // materialize it so we can use its internal NIO buffer
+ frameBuffer.ensureWritable(frameSize);
- ByteBuffer buf = ByteBuffer.allocate(frameSize);
+ if (position == 0 && sender.getLocalState() !=
EndpointState.CLOSED && position < bodySize) {
Review comment:
> > e.g there are no delivery-annotations or header in the original message
to skip past, or the subsequently generated ones precisely fit in the buffer
with room for nothing else, or the connection was flow controlled before
sending anything else
>
> If there are no delivery annotations or header, the deliveryInitialPacket
takes care filling the rest of the frame with some file content (and that
should be at least one byte, but this is a missing check yet, indeed),
increasing position over 0.
True, forgot that.
> If flow control kick in, it would happen before doing it, hence only close
or available Netty outbound buffer would resume it (with position still == 0).
> Assuming that files contains at least a single byte, using position == 0
should be safe, logically, despite not very intuitive.
I meant flow control after sending the initial packet, in the loop. There
are 2 routes that it is possible (but unlikely, I admit) to get into the loop
without incrementing the position field, which would mean it could go through
the initial stuff again and generate the initial packet again if it flow
controls.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]