diff --git a/source/v5/mqtt5_client.c b/source/v5/mqtt5_client.c index b5686155..8f9ca3dc 100644 --- a/source/v5/mqtt5_client.c +++ b/source/v5/mqtt5_client.c @@ -697,30 +697,6 @@ static void s_aws_mqtt5_client_shutdown_channel_clean( aws_mqtt5_operation_disconnect_release(disconnect_op); } -struct aws_mqtt5_shutdown_task { - struct aws_task task; - struct aws_allocator *allocator; - int error_code; - struct aws_mqtt5_client *client; -}; - -static void s_mqtt5_client_shutdown_final(int error_code, struct aws_mqtt5_client *client); - -static void s_shutdown_task_fn(struct aws_task *task, void *arg, enum aws_task_status status) { - (void)task; - - struct aws_mqtt5_shutdown_task *shutdown_task = arg; - if (status != AWS_TASK_STATUS_RUN_READY) { - goto done; - } - - s_mqtt5_client_shutdown_final(shutdown_task->error_code, shutdown_task->client); - -done: - - aws_mem_release(shutdown_task->allocator, shutdown_task); -} - static void s_mqtt5_client_shutdown_final(int error_code, struct aws_mqtt5_client *client) { AWS_FATAL_ASSERT(aws_event_loop_thread_is_callers_thread(client->loop)); @@ -764,19 +740,8 @@ static void s_mqtt5_client_shutdown( error_code = AWS_ERROR_MQTT_UNEXPECTED_HANGUP; } - if (aws_event_loop_thread_is_callers_thread(client->loop)) { - s_mqtt5_client_shutdown_final(error_code, client); - return; - } - - struct aws_mqtt5_shutdown_task *shutdown_task = - aws_mem_calloc(client->allocator, 1, sizeof(struct aws_mqtt5_shutdown_task)); - - aws_task_init(&shutdown_task->task, s_shutdown_task_fn, (void *)shutdown_task, "ShutdownTask"); - shutdown_task->allocator = client->allocator; - shutdown_task->client = client; - shutdown_task->error_code = error_code; - aws_event_loop_schedule_task_now(client->loop, &shutdown_task->task); + AWS_FATAL_ASSERT(aws_event_loop_thread_is_callers_thread(client->loop)); + s_mqtt5_client_shutdown_final(error_code, client); } static void s_mqtt5_client_setup(