Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove no-longer-necessary setup callback cross-thread task #341

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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