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

Protect access to the taskid to deal with different threads. #403

Merged
merged 1 commit into from Oct 7, 2020

Conversation

thomasvl
Copy link
Member

@thomasvl thomasvl commented Oct 6, 2020

The requests can be made on one thread, but the expire on another thread.
tsan flagged this potential race, so add the needed guards so the access
is as safe as possible given the system api's required usage.

The requests can be made on one thread, but the expire on another thread.
tsan flagged this potential race, so add the needed guards so the access
is as safe as possible given the system api's required usage.
@google-cla google-cla bot added the cla: yes label Oct 6, 2020
@synchronized(self) {
if (bgTaskID == self.backgroundTaskIdentifier) {
if (localTaskID == self.backgroundTaskIdentifier) {
Copy link

Choose a reason for hiding this comment

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

Is there utility to this check anymore, given that guardedTaskID is set inside the @synchronized(self) block below and read in an @synchronized(self) block above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, if there is a race with starting a retry, then we'll already be on to the new taskid, so when the first one's expire fires, we don't want to break the connection to the new one, just clean up the old one by ending it.

@thomasvl thomasvl merged commit e4b4e6f into google:master Oct 7, 2020
@thomasvl thomasvl deleted the tsan_taskid branch October 7, 2020 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants