Skip to content

Commit

Permalink
make sure any operation staistics changes happen in locks (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedTwigleg committed Jan 25, 2023
1 parent 6668ffd commit 33c3455
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions source/client_channel_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,15 @@ static void s_request_outgoing_task(struct aws_channel_task *task, void *arg, en
(void *)request->connection,
request->packet_id);

/* Set the request as incomplete and un-acked in the operation statistics */
aws_mqtt_connection_statistics_change_operation_statistic_state(
request->connection, request, AWS_MQTT_OSS_INCOMPLETE | AWS_MQTT_OSS_UNACKED);
{ /* BEGIN CRITICAL SECTION */
mqtt_connection_lock_synced_data(connection);

/* Set the request as incomplete and un-acked in the operation statistics */
aws_mqtt_connection_statistics_change_operation_statistic_state(
request->connection, request, AWS_MQTT_OSS_INCOMPLETE | AWS_MQTT_OSS_UNACKED);

mqtt_connection_unlock_synced_data(connection);
} /* END CRITICAL SECTION */

/* Put the request into the ongoing list */
aws_linked_list_push_back(&connection->thread_data.ongoing_requests_list, &request->list_node);
Expand Down Expand Up @@ -939,16 +945,15 @@ uint16_t mqtt_create_request(
aws_channel_acquire_hold(channel);
}

mqtt_connection_unlock_synced_data(connection);
if (next_request && next_request->packet_size > 0) {
/* Set the status as incomplete */
aws_mqtt_connection_statistics_change_operation_statistic_state(
next_request->connection, next_request, AWS_MQTT_OSS_INCOMPLETE);
}

mqtt_connection_unlock_synced_data(connection);
} /* END CRITICAL SECTION */

if (next_request && next_request->packet_size > 0) {
/* Set the status as incomplete */
aws_mqtt_connection_statistics_change_operation_statistic_state(
next_request->connection, next_request, AWS_MQTT_OSS_INCOMPLETE);
}

if (should_schedule_task) {
AWS_LOGF_TRACE(
AWS_LS_MQTT_CLIENT,
Expand Down

0 comments on commit 33c3455

Please sign in to comment.