Skip to content

Commit

Permalink
Cancel service task on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Mar 14, 2024
1 parent ccf6ac8 commit 96e63a7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/request-response/request_response_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ static void s_mqtt_request_response_client_external_shutdown_task_fn(
/* stop handling adapter event callbacks */
client->state = AWS_RRCS_SHUTTING_DOWN;

if (client->scheduled_service_timepoint_ns != 0) {
aws_event_loop_cancel_task(client->loop, &client->service_task);
client->scheduled_service_timepoint_ns = 0;
}

aws_rr_subscription_manager_clean_up(&client->subscription_manager);

if (client->client_adapter != NULL) {
Expand All @@ -546,6 +551,12 @@ static void s_mqtt_request_response_client_wake_service(struct aws_mqtt_request_
uint64_t now = 0;
aws_high_res_clock_get_ticks(&now);

AWS_FATAL_ASSERT(aws_event_loop_thread_is_callers_thread(client->loop));

if (client->state != AWS_RRCS_ACTIVE) {
return;
}

if (client->scheduled_service_timepoint_ns == 0 || now < client->scheduled_service_timepoint_ns) {
if (now < client->scheduled_service_timepoint_ns) {
aws_event_loop_cancel_task(client->loop, &client->service_task);
Expand Down

0 comments on commit 96e63a7

Please sign in to comment.