Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,15 @@ NetworkMesh::NetworkMesh()
{
SteamNetworkingUtils()->SetGlobalConfigValueInt32(k_ESteamNetworkingConfig_LogLevel_P2PRendezvous, k_ESteamNetworkingSocketsDebugOutputType_Error);

// Block the status-changed callback from firing while the library is
// torn down and re-initialized. Without this guard the callback can
// be dispatched (e.g. from a previous Tick's RunCallbacks queue) after
// GameNetworkingSockets_Kill() has freed its internal mutexes but
// before GameNetworkingSockets_Init() has rebuilt them, resulting in
// an EXCEPTION_ACCESS_VIOLATION_READ on a null mutex pointer inside
// mtx_do_lock.
g_bNetworkMeshDestroying.store(true);

// try a shutdown
GameNetworkingSockets_Kill();

Expand Down Expand Up @@ -658,6 +667,10 @@ NetworkMesh::NetworkMesh()

SteamNetworkingUtils()->SetGlobalCallback_SteamNetConnectionStatusChanged(OnSteamNetConnectionStatusChanged);

// Library is fully re-initialized and the callback is registered;
// it is now safe to allow OnSteamNetConnectionStatusChanged to run.
g_bNetworkMeshDestroying.store(false);

ESteamNetworkingSocketsDebugOutputType logType =
#if defined(_DEBUG)
ESteamNetworkingSocketsDebugOutputType::k_ESteamNetworkingSocketsDebugOutputType_Debug
Expand Down
Loading