From 23d6b52b517969ee42a403b7780e9b7c354f5df5 Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Mon, 21 Aug 2023 09:23:05 -0700 Subject: [PATCH] Address theoretical possibility of a TPS-throttled getting lost --- source/v5/mqtt5_client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/v5/mqtt5_client.c b/source/v5/mqtt5_client.c index 74afcb6b..1acc8e91 100644 --- a/source/v5/mqtt5_client.c +++ b/source/v5/mqtt5_client.c @@ -3025,14 +3025,18 @@ int aws_mqtt5_client_service_operational_state(struct aws_mqtt5_client_operation struct aws_mqtt5_operation *next_operation = NULL; while (!aws_linked_list_empty(&client_operational_state->queued_operations)) { struct aws_linked_list_node *next_operation_node = - aws_linked_list_pop_front(&client_operational_state->queued_operations); + aws_linked_list_front(&client_operational_state->queued_operations); struct aws_mqtt5_operation *operation = AWS_CONTAINER_OF(next_operation_node, struct aws_mqtt5_operation, node); + /* If this is a publish and we're throttled, just quit out of the loop. */ if (s_apply_publish_tps_flow_control(client, operation)) { break; } + /* Wait until flow control has passed before actually dequeuing the operation. */ + aws_linked_list_pop_front(&client_operational_state->queued_operations); + if (!aws_mqtt5_operation_validate_vs_connection_settings(operation, client)) { next_operation = operation; break;