Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current
messagesender_close
function starts by clearing any pending messages by callingon_message_send_complete
with an error state, and then attempts to detach the link.However, if the link detach should fail for any reason (say, the connection is in an error state), then the link will also attempt to remove it's pending deliveries (
on_session_state_change
->remove_all_pending_deliveries
) which also calls theon_message_send_complete
callback a second time.This has the potential to fail in two ways - first, the
on_message_send_complete
callback must be idempotent (which the amqp_managementon_message_send_complete
is not) and secondly, the message has already been freed by the time the link attempts to settle it.By moving the
indicate_all_messages_as_error
call to after the attempted detach, if the link fails to detach it will settle any pending messages and remove them from the message sender, thereby eliminating the double callback.