-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix race condition with aws_s3_endpoint acquire/release #209
Conversation
source/s3_client.c
Outdated
|
||
/* not calling aws_s3_endpoint_acquire() because that would grab the client lock */ | ||
AWS_ASSERT(endpoint->client_synced_data.ref_count > 0); | ||
++endpoint->client_synced_data.ref_count; |
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.
this seems to contradict pr description that we should always hold lock on refcount changes
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.
I'll change the comment to be more clear
we already HAVE the lock here in this code, is why we're not calling that other function
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.
actually, I did something else
took away comment and made the code self-documenting
we DO call the function now, but pass in an arg to say that we're holding the lock
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.
Fix & ship.
struct aws_ref_count ref_count; | ||
struct { | ||
/* This is NOT an atomic ref-count. | ||
* The endpoint lives in hashtable: `aws_s3_client.threaded_data.endpoints` |
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: aws_s3_client.threaded_data.endpoints
is it out of date?
see: awslabs/aws-c-s3#209 Update submodules to latest: aws-c-io: v0.13.2 -> v0.13.4 aws-c-s3: v0.1.46 -> v0.1.48 aws-lc: v1.1.0 -> v1.2.0 s2n: v1.3.20 -> v1.3.21
see: awslabs/aws-c-s3#209 Update submodules to latest: aws-c-io: v0.13.2 -> v0.13.4 aws-c-s3: v0.1.46 -> v0.1.48 aws-lc: v1.1.0 -> v1.2.0 s2n: v1.3.20 -> v1.3.21
*Issue #:* awslabs/aws-c-s3#202 *Description of changes:* update aws-c-s3 submodule, containing fix from PR awslabs/aws-c-s3#209
Issue:
#202
There are race conditions around the removal of endpoints from the client's hashtable
Description of changes:
aws_s3_endpoint
Rambling:
This isn't our first time trying to fix these race conditions. See:
We also considered moving the endpoint hashtable out of
synced_data
and ontothread_data
, and changingaws_s3_acquire()/release()
calls so they become scheduled tasks under the hood. But this would have been a significant refactor. Once I'd spent 2 days staring at this code I understood it well enough to (hopefully) fix it with a small change.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.