Skip to content

Commit

Permalink
Merge branch 'main' into error_suback
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera authored Jan 16, 2024
2 parents 326eecd + 171840f commit f609a22
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions source/v5/mqtt5_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f609a22

Please sign in to comment.