Skip to content

Fix races related to the way how authLock is implemented and used #170

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

Merged
merged 3 commits into from
Oct 6, 2021
Merged

Fix races related to the way how authLock is implemented and used #170

merged 3 commits into from
Oct 6, 2021

Conversation

yuri-per
Copy link
Contributor

1. Allocate authLock as part of Connection

Previously when Authenticate() or Authenticated() was called simultaneously from several goroutines authLock was initialized in racy manner. Such code is not allowed by Go Memory Model and sometimes crashes.

2. Introduce GetStorageUrl() method

Access to StorageUrl without taking authLock is racy. New method GetStorageUrl() is added for getting StorageLock in race-free manner. Methods where StorageUrl was accessed without lock (QueryInfo() and ObjectTempUrl()) are updated.

yuri-per added 3 commits May 12, 2021 10:27
Previously when Authenticate() or Authenticated() was called simultaneously
from several goroutines authLock was initialized in racy manner.
Such code is not allowed by Go Memory Model and sometimes crashes.
Access to StorageUrl without taking authLock is racy.
New method GetStorageUrl() is added for getting StorageLock in race-free manner.
Methods where StorageUrl was accessed without lock (QueryInfo() and ObjectTempUrl()) are updated.
This change is required to pass CI tests.
Copy link
Owner

@ncw ncw left a comment

Choose a reason for hiding this comment

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

This looks great - thank you for fixing this up.

I wrote this code when I was a go n00b and now you've pointed it out it is horrible, so thank you for fixing it.

I'll merge this now.

@ncw ncw merged commit e8c1ee3 into ncw:master Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants