-
Notifications
You must be signed in to change notification settings - Fork 851
Shutdown hook should grab the lock if there is one #4919
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
Conversation
|
Talk to @shinrich - she had the same problem and we tweaked a call (I think the mutex locking) to transparently deal with null mutexes. Also, please work with @dyrock on plugin coordination - one of the points of that is to unify this kind of code so bugs like this don't have to stepped on one place at a time. |
|
Yes, we tidied up the mutex try lock to gracefully handle the null mutex case. Need to remember where we made that change. |
|
See #4926. |
1ecc844 to
b6bf972
Compare
src/traffic_server/traffic_server.cc
Outdated
| APIHook *hook = lifecycle_hooks->get(TS_LIFECYCLE_SHUTDOWN_HOOK); | ||
| while (hook) { | ||
| hook->invoke(TS_EVENT_LIFECYCLE_SHUTDOWN, nullptr); | ||
| if (hook->m_cont->mutex) { |
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.
Why not
while (hook) {
SCOPED_MUTEX_LOCK(lock, hook->m_cont->mutex, this_ethread());
hook->invoke(TS_EVENT_LIFECYCLE_SHUTDOWN, nullptr);
hook = hook->next;
}
?
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.
So the lock object will be a harmless do-nothing if the mutex is null?
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.
Yes. It was designed that way precisely to get this effect. Better to check the null in one place, and not every callsite.
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.
To be OCD about not holding mutexes longer than necessary, I would prefer:
while (hook) {
{
SCOPED_MUTEX_LOCK(lock, hook->m_cont->mutex, this_ethread());
hook->invoke(TS_EVENT_LIFECYCLE_SHUTDOWN, nullptr);
}
hook = hook->next;
}
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.
It's during shutdown, I think I want it to hold it for longer, might expose other problems in the code.
b6bf972 to
6eab7b3
Compare
6eab7b3 to
6ab78ee
Compare
This was causing some crashes during shutdown.