File tree Expand file tree Collapse file tree
GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -566,6 +566,15 @@ NetworkMesh::NetworkMesh()
566566{
567567 SteamNetworkingUtils ()->SetGlobalConfigValueInt32 (k_ESteamNetworkingConfig_LogLevel_P2PRendezvous, k_ESteamNetworkingSocketsDebugOutputType_Error);
568568
569+ // Block the status-changed callback from firing while the library is
570+ // torn down and re-initialized. Without this guard the callback can
571+ // be dispatched (e.g. from a previous Tick's RunCallbacks queue) after
572+ // GameNetworkingSockets_Kill() has freed its internal mutexes but
573+ // before GameNetworkingSockets_Init() has rebuilt them, resulting in
574+ // an EXCEPTION_ACCESS_VIOLATION_READ on a null mutex pointer inside
575+ // mtx_do_lock.
576+ g_bNetworkMeshDestroying.store (true );
577+
569578 // try a shutdown
570579 GameNetworkingSockets_Kill ();
571580
@@ -658,6 +667,10 @@ NetworkMesh::NetworkMesh()
658667
659668 SteamNetworkingUtils ()->SetGlobalCallback_SteamNetConnectionStatusChanged (OnSteamNetConnectionStatusChanged);
660669
670+ // Library is fully re-initialized and the callback is registered;
671+ // it is now safe to allow OnSteamNetConnectionStatusChanged to run.
672+ g_bNetworkMeshDestroying.store (false );
673+
661674 ESteamNetworkingSocketsDebugOutputType logType =
662675#if defined(_DEBUG)
663676 ESteamNetworkingSocketsDebugOutputType::k_ESteamNetworkingSocketsDebugOutputType_Debug
You can’t perform that action at this time.
0 commit comments