Github user alanconway commented on a diff in the pull request:
https://github.com/apache/qpid-dispatch/pull/172#discussion_r126161603
--- Diff: src/message.c ---
@@ -996,21 +1094,47 @@ qd_message_t *qd_message_receive(pn_delivery_t
*delivery)
}
//
+ // The discard flag indicates if we should continue receiving the
message.
+ // This is pertinent in the case of large messages. When large
messages are being received, we try to send out part of the
+ // message that has been received so far. If we not able to send it
anywhere, there is no need to keep creating buffers
+ //
+ bool discard = qd_message_is_discard((qd_message_t*)msg);
+
+ //
// Get a reference to the tail buffer on the message. This is the
buffer into which
- // we will store incoming message data. If there is no buffer in the
message, allocate
- // an empty one and add it to the message.
+ // we will store incoming message data. If there is no buffer in the
message, this is the
+ // first time we are here and we need to allocate an empty one and add
it to the message.
//
- buf = DEQ_TAIL(msg->content->buffers);
- if (!buf) {
- buf = qd_buffer();
- DEQ_INSERT_TAIL(msg->content->buffers, buf);
+ if (!discard) {
+ buf = DEQ_TAIL(msg->content->buffers);
+ if (!buf) {
+ buf = qd_buffer();
+ DEQ_INSERT_TAIL(msg->content->buffers, buf);
+ }
}
while (1) {
- //
- // Try to receive enough data to fill the remaining space in the
tail buffer.
- //
- rc = pn_link_recv(link, (char*) qd_buffer_cursor(buf),
qd_buffer_capacity(buf));
+ if (discard) {
+ char dummy[BUFFER_SIZE];
--- End diff --
Pity that we have to copy out data only to throw it away, but I think you
are correct that we do need to do it. Maybe the AMQP spec has something we can
use to abort an incoming message, but even if it does this code path is
probably needed as a fall-back.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]