This is an automated email from the ASF dual-hosted git repository. kgiusti pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push: new 2b7c0fc DISPATCH-1590: ensure msg content buffer list is valid on fanout 2b7c0fc is described below commit 2b7c0fcb0dd2e4749fb8e69eafa45f790c4fd363 Author: Kenneth Giusti <kgiu...@apache.org> AuthorDate: Mon Mar 9 09:37:05 2020 -0400 DISPATCH-1590: ensure msg content buffer list is valid on fanout --- src/message.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/message.c b/src/message.c index 6e0d120..77ac056 100644 --- a/src/message.c +++ b/src/message.c @@ -1162,20 +1162,27 @@ void qd_message_add_fanout(qd_message_t *in_msg, LOCK(content->lock); ++content->fanout; - // do not free the buffers until all fanout senders are done with them qd_buffer_t *buf = DEQ_HEAD(content->buffers); - if (buf) { - // DISPATCH-1330: since we're incrementing the refcount be sure to set - // the cursor to the head buf in case msg is discarded before all data - // is sent (we'll decref any unsent buffers at that time) - // - msg->cursor.buffer = buf; - - while (buf) { - qd_buffer_inc_fanout(buf); - buf = DEQ_NEXT(buf); - } + // DISPATCH-1590: content->buffers may not be set up yet if + // content->pending is the first buffer and it is not yet full. + if (!buf) { + // assumption: proton will never signal a readable delivery if there is + // no data at all. + assert(content->pending && qd_buffer_size(content->pending) > 0); + DEQ_INSERT_TAIL(content->buffers, content->pending); + content->pending = 0; + buf = DEQ_HEAD(content->buffers); + } + // DISPATCH-1330: since we're incrementing the refcount be sure to set + // the cursor to the head buf in case msg is discarded before all data + // is sent (we'll decref any unsent buffers at that time) + // + msg->cursor.buffer = buf; + while (buf) { + qd_buffer_inc_fanout(buf); + buf = DEQ_NEXT(buf); } + UNLOCK(content->lock); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org