-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
srs reusable thread need join #559
Conversation
This is because if the thread exits on its own, there is no need to go through the complicated process of disposing, waiting for the thread to exit, and confirming the exit, etc.
|
Or in the second case, you can actively call join:
Then set disposed=true.
|
Can join be called in the current thread? It should be called in another thread, right?
|
Makes sense, I think you just removed these few lines. It will run again in the dispose, so it's not a problem.
|
Yeah, I feel the same way. If there's no need to join, just skip it. And the while loop below will also exit directly, so there's no significant consumption.
|
👍 Please update the pr. |
This pr fixed the #553 |
srs reusable thread need join
Merged to develop: eac5440 |
Let me describe the problem in detail.
In the function SrsThread::stop(), the variable "loop" is set to false first, and then the function SrsThread::dispose() is executed.
In the function SrsThread::thread_cycle(), the variable "disposed" is set to true when exiting the loop.
In this way, it is possible for the variable "disposed" to be assigned true before executing SrsThread::dispose(), causing the function SrsThread::dispose() to directly return.
There is another issue. I commented out a line of code. The description above is for issue #546. I think the occurrence of issue #546 is because the assignment of "disposed" is executed after handler->on_thread_stop(). For SrsConnection, deleting itself is done in handler->on_thread_stop(), which means freeing the current thread. Therefore, any operation after handler->on_thread_stop() will result in an error.
TRANS_BY_GPT3