Skip to content

Acquire event loop group from event loop #516

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions source/connection_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ static void s_aws_http_connection_manager_finish_destroy(struct aws_http_connect
aws_mem_release(manager->allocator, manager->cull_task);
}

aws_event_loop_group_release_from_event_loop(manager->cull_event_loop);

aws_mutex_clean_up(&manager->lock);

aws_client_bootstrap_release(manager->bootstrap);
Expand Down Expand Up @@ -852,6 +854,8 @@ static void s_schedule_culling(struct aws_http_connection_manager *manager) {

if (manager->cull_event_loop == NULL) {
manager->cull_event_loop = aws_event_loop_group_get_next_loop(manager->bootstrap->event_loop_group);
// Acquire the event loop group to make sure it doesn't get destroyed while we are using the event loop.
aws_event_loop_group_acquire_from_event_loop(manager->cull_event_loop);
}
AWS_FATAL_ASSERT(manager->cull_event_loop != NULL);

Expand Down
5 changes: 5 additions & 0 deletions source/http2_stream_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ static void s_finish_pending_stream_acquisitions_task(struct aws_task *task, voi
stream_manager, &pending_stream_acquisitions, AWS_ERROR_HTTP_STREAM_MANAGER_SHUTTING_DOWN);
aws_mem_release(stream_manager->allocator, task);
s_aws_http2_stream_manager_execute_transaction(&work);
aws_event_loop_group_release_from_event_loop(stream_manager->finish_pending_stream_acquisitions_task_event_loop);
}

/* helper function for building the transaction: how many new connections we should request */
Expand Down Expand Up @@ -379,6 +380,10 @@ static void s_aws_http2_stream_manager_build_transaction_synced(struct aws_http2
/* schedule a task to finish the pending acquisitions if there doesn't have one and needed */
stream_manager->finish_pending_stream_acquisitions_task_event_loop =
aws_event_loop_group_get_next_loop(stream_manager->bootstrap->event_loop_group);
/* Acquire a refcount for the task , released when task finished
* s_finish_pending_stream_acquisitions_task */
aws_event_loop_group_acquire_from_event_loop(
stream_manager->finish_pending_stream_acquisitions_task_event_loop);
struct aws_task *finish_pending_stream_acquisitions_task =
aws_mem_calloc(stream_manager->allocator, 1, sizeof(struct aws_task));
aws_task_init(
Expand Down