-
Notifications
You must be signed in to change notification settings - Fork 40
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
Endpoint lifetime fix #208
Conversation
Thank you for providing a fix. We will look at this at a later stage, need to do some testing. |
struct aws_task *async_release_task = aws_mem_calloc(client->allocator, 1, sizeof(struct aws_task)); | ||
aws_task_init(async_release_task, s_endpoint_release_task, endpoint, "se_endpoint_refcount_task"); | ||
|
||
endpoint->async_release.client = client; | ||
endpoint->async_release.task = async_release_task; | ||
endpoint->async_release.task_scheduled = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial: should this endpoint initialization code go in in s3_endpoint.c instead of s3_client.c?
struct aws_s3_client *client; | ||
/* If set, the release of endpoint will be scheduled to run within the task to prevent the data race with client | ||
*/ | ||
struct aws_task *task; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why create a new task just for this? why not re-use the client's existing process_work_task
?
we could keep an aws_array_list of struct aws_s3_endpoint*
to be released
size_t current_ref = aws_atomic_load_int(&endpoint->ref_count.ref_count); | ||
num_released = endpoint->async_release.num_released; | ||
endpoint->async_release.num_released = 0; | ||
AWS_ASSERT(num_released <= current_ref); | ||
if (num_released == current_ref) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count might have changed from another thread
/* The last refcount to release */ | ||
if (aws_atomic_load_int(&endpoint->ref_count.ref_count) == 1) { | ||
aws_hash_table_remove(&client->synced_data.endpoints, endpoint->host_name, NULL, NULL); | ||
if (endpoint->async_release.task) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of endpoint having 2 "modes", where 1 mode is never used
just needless complexity
I took another swing at fixing this over in a new PR: #209 |
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.