-
Notifications
You must be signed in to change notification settings - Fork 23
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
Set PThread::m_isRunning
early, when the thread is created
#16
Set PThread::m_isRunning
early, when the thread is created
#16
Conversation
This allows PThread::IsTerminated to return false as soon as the thread is created, which may be earlier than PThread::PX_ThreadStart manages to set it. This should fix issues when the code synchronously tests if the thread is terminated soon after spawning it.
When testing with callgen323 the crash during runtime is gone for me with this patch and Valgrind doesn't complain either. I do get a crash in the exit handler though and one of the registration threads seems to hang a few seconds. (gdb) bt |
This seems like a global initialization/termination order issue. |
My tests are good too with this patch. After sleeping on it I see moving the setting of m_isrunning also moves it from the new thread to the starter thread, which is not just a quantitative (a bit earlier), but a qualitative change, as it closes the race condition where the starter can see the new thread as terminated after the PThread start methods returns but before it runs. Also h323+ was not stopping properly in my code, the daemon hung forever or was killed by systemctl, now it terminates properly. It was caused by the same pthread_kill problem and is fixed now. |
This allows
PThread::IsTerminated
to return false as soon as the thread is created, which may be earlier thanPThread::PX_ThreadStart
manages to set it. This should fix issues when the code synchronously tests if the thread is terminated soon after spawning it.This may fix issues reported in comments to #11.