Skip to content

Commit 4716189

Browse files
committed
pr changes/fixes
1 parent 37741c0 commit 4716189

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

include/aws/mqtt/v5/mqtt5_client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ int aws_mqtt5_client_publish(
759759
/**
760760
* Takes manual control of PUBACK for the given PUBLISH packet.
761761
*
762+
* This MUST only be called from within the publish received callback. A return value of 0 indicates an
763+
* invalid control id.
764+
*
762765
* @param client mqtt5 client that received the PUBLISH packet to take manual PUBACK control from.
763766
* @param publish_view the view of the PUBLISH packet that PUBACK control is taken from.
764767
* @return puback_control_id of the PUBLISH packet. This can be used to schedule a PUBACK for the PUBLISH packet

source/v5/mqtt5_client.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,6 @@ static void s_aws_mqtt5_client_connected_on_packet_received(
19581958

19591959
s_aws_mqtt5_client_shutdown_channel(client, error_code);
19601960
}
1961-
return;
19621961
}
19631962
}
19641963
break;
@@ -2667,9 +2666,7 @@ uint64_t aws_mqtt5_client_acquire_puback(
26672666
struct aws_mqtt5_manual_puback_entry *manual_puback =
26682667
s_aws_mqtt_manual_puback_entry_new(client->allocator, publish_view->packet_id, current_control_packet_id);
26692668

2670-
/* Allows lookup of manual puback entries by packet id. We incref here because the packet_id table also has a ref to
2671-
* the manual_puback */
2672-
aws_ref_count_acquire(&manual_puback->ref_count);
2669+
/* Allows lookup of manual puback entries by packet id. */
26732670
if (aws_hash_table_put(
26742671
&client->operational_state.manual_puback_packet_id_table, &manual_puback->packet_id, manual_puback, NULL)) {
26752672
int error_code = aws_last_error();
@@ -2681,6 +2678,8 @@ uint64_t aws_mqtt5_client_acquire_puback(
26812678
aws_error_debug_str(error_code));
26822679
goto cleanup;
26832680
}
2681+
/* We incref here because the packet_id table also has a ref to the manual_puback */
2682+
aws_ref_count_acquire(&manual_puback->ref_count);
26842683

26852684
/* Allows lookup of manual puback entries by control id */
26862685
if (aws_hash_table_put(

0 commit comments

Comments
 (0)