-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
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 think the order of events at unlock should be changed, see comments.
} | ||
|
||
// Cleanup | ||
l.locked = 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.
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
.
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.
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.
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.
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.
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.
Agreed.
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.
LGTM
} | ||
|
||
// Cleanup | ||
l.locked = 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.
Agreed.
This PR extends #106