Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset link credit on last transfer legally received #465

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

ewertons
Copy link
Collaborator

This is a problematic code, since if the current credit is already zero, the sender will not have sent another transfer.

else if (is_transfer_type_by_descriptor(descriptor))
{
    if (link_instance->on_transfer_received != NULL)
    {
        TRANSFER_HANDLE transfer_handle;
        if (amqpvalue_get_transfer(performative, &transfer_handle) != 0)
        {
            LogError("Cannot get transfer performative");
        }
        else
        {
            AMQP_VALUE delivery_state;
            bool more;
            bool is_error;

            if (link_instance->current_link_credit == 0)

That can be verified in the AMQP 1.0 spec in "2.6.7 Flow Control": "If the link-credit is less than or equal to zero, i.e. the delivery-count is the same as or greater than the delivery-limit, it is illegal to send more messages."

Here the code is already automatically replenishing the link credit if it gets "too low". In such case, it should check if the link credit gets down to 1 or less (for the last message that the sender can legally send) and then replenish, also sending a new flow to the sender.

Btw, this is a new bug caused by this change:
https://github.com/Azure/azure-uamqp-c/pull/383/files

The current issue that best matches this bug is #461

This is a problematic code, since if the current credit is already zero, the sender will not have sent another transfer.

    else if (is_transfer_type_by_descriptor(descriptor))
    {
        if (link_instance->on_transfer_received != NULL)
        {
            TRANSFER_HANDLE transfer_handle;
            if (amqpvalue_get_transfer(performative, &transfer_handle) != 0)
            {
                LogError("Cannot get transfer performative");
            }
            else
            {
                AMQP_VALUE delivery_state;
                bool more;
                bool is_error;

                if (link_instance->current_link_credit == 0)

That can be verified in the AMQP 1.0 spec in "2.6.7 Flow Control":
"If the link-credit is less than or equal to zero, i.e. the delivery-count is the same as or greater than the delivery-limit, it is illegal to send more messages."

Here the code is already automatically replenishing the link credit if it gets "too low".
In such case, it should check if the link credit gets down to 1 or less (for the last message that the sender can legally send) and then replenish, also sending a new flow to the sender.

Btw, this is a new bug caused by this change:
https://github.com/Azure/azure-uamqp-c/pull/383/files

The current issue that best matches this bug is #461
@ericwolz
Copy link
Contributor

UT needed?

@ewertons
Copy link
Collaborator Author

UT needed?

Added.

@ewertons ewertons merged commit 6a150b0 into master Jun 19, 2024
16 checks passed
@ewertons ewertons deleted the ewertons/gh461 branch June 19, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants