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

Added ServerID function #107

Merged
merged 2 commits into from
Apr 17, 2018
Merged

Added ServerID function #107

merged 2 commits into from
Apr 17, 2018

Conversation

ewoutp
Copy link
Contributor

@ewoutp ewoutp commented Apr 17, 2018

This PR extends #106

@ewoutp ewoutp requested a review from neunhoef April 17, 2018 09:30
Copy link
Member

@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

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

I think the order of events at unlock should be changed, see comments.

}

// Cleanup
l.locked = false
Copy link
Member

Choose a reason for hiding this comment

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

I think here is a data race: You first remove the key in the agency, then set locked to false (irrelevant here), and only then stop the renewal. I suggest to first cancel the renewal, make sure it is cancelled (unless l.cancelRenewal() does this automatically), then remove the key and only then set locked to false.

Copy link
Member

Choose a reason for hiding this comment

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

OK, now I understand, the renewal has a precondition as well. OK, this is good. Nevertheless, I think the change of order makes the code easier understandable. Furthermore, If the RemoveKeyIfEqualTo fails, then the renewal go routine might keep running. If we have cancelled first, it is gone in any case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this function (and the renewal) first claim an in-memory mutex.
So there can be no race.

Second. If RemoveKeyIfEqualTo fails, the lock is likely still held, so I expect the renewal to continue.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed.

Copy link
Member

@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

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

LGTM

}

// Cleanup
l.locked = false
Copy link
Member

Choose a reason for hiding this comment

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

Agreed.

@ewoutp ewoutp merged commit 9186390 into master Apr 17, 2018
@ewoutp ewoutp deleted the server-id branch April 17, 2018 11:15
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