mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Fix deadlock when calling StopConnection() during connection startup
This commit is contained in:
parent
581f92ee7c
commit
5b8e4e3abe
15
main.cpp
15
main.cpp
@ -58,10 +58,6 @@ void MoonlightInstance::OnConnectionStopped(uint32_t error) {
|
|||||||
// Unlock the mouse
|
// Unlock the mouse
|
||||||
UnlockMouse();
|
UnlockMouse();
|
||||||
|
|
||||||
// Join threads
|
|
||||||
pthread_join(m_ConnectionThread, NULL);
|
|
||||||
pthread_join(m_GamepadThread, NULL);
|
|
||||||
|
|
||||||
// Notify the JS code that the stream has ended
|
// Notify the JS code that the stream has ended
|
||||||
pp::Var response(MSG_STREAM_TERMINATED);
|
pp::Var response(MSG_STREAM_TERMINATED);
|
||||||
PostMessage(response);
|
PostMessage(response);
|
||||||
@ -80,6 +76,17 @@ void MoonlightInstance::StopConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* MoonlightInstance::StopThreadFunc(void* context) {
|
void* MoonlightInstance::StopThreadFunc(void* context) {
|
||||||
|
// We must join the connection thread first, because LiStopConnection must
|
||||||
|
// not be invoked during LiStartConnection.
|
||||||
|
pthread_join(g_Instance->m_ConnectionThread, NULL);
|
||||||
|
|
||||||
|
// Not running anymore
|
||||||
|
g_Instance->m_Running = false;
|
||||||
|
|
||||||
|
// We also need to stop this thread after the connection thread, because it depends
|
||||||
|
// on being initialized there.
|
||||||
|
pthread_join(g_Instance->m_GamepadThread, NULL);
|
||||||
|
|
||||||
// Stop the connection
|
// Stop the connection
|
||||||
LiStopConnection();
|
LiStopConnection();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user