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

Cache the Error Before Any Side Effects #619

Merged
merged 2 commits into from
Jan 25, 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
6 changes: 5 additions & 1 deletion source/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,16 @@ static struct aws_event_loop_group *s_event_loop_group_new(

return el_group;

on_error:
on_error:;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; _ ;

/* cache the error code to prevent any potential side effects */
int cached_error_code = aws_last_error();

aws_mem_release(alloc, usable_cpus);
s_aws_event_loop_group_shutdown_sync(el_group);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is one of those throwing some new error because it cant clean up correctly? should we fix that as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's code in here that loops through a priority list until it raises the AWS_ERROR_PRIORITY_QUEUE_EMPTY, indicating it's empty.

So it's not an error-as-fail, it's an error-code-as-flow-control

s_event_loop_group_thread_exit(el_group);

/* raise the cached error code */
aws_raise_error(cached_error_code);
return NULL;
}

Expand Down