Skip to content

Commit

Permalink
Acquire connectionLock in CMClient::Disconnected to handle concurrent…
Browse files Browse the repository at this point in the history
… Disconnected race
  • Loading branch information
azuisleet committed Dec 29, 2017
1 parent 2c02f01 commit e681328
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions SteamKit2/SteamKit2/Steam/CMClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,19 @@ void Disconnected( object sender, DisconnectedEventArgs e )
SessionID = null;
SteamID = null;

lock ( connectionLock )
{
if ( connection == null ) return;

connection.NetMsgReceived -= NetMsgReceived;
connection.Connected -= Connected;
connection.Disconnected -= Disconnected;
connection = null;
connection.NetMsgReceived -= NetMsgReceived;
connection.Connected -= Connected;
connection.Disconnected -= Disconnected;
connection = null;

heartBeatFunc.Stop();
heartBeatFunc.Stop();

OnClientDisconnected( userInitiated: e.UserInitiated || ExpectDisconnection );
OnClientDisconnected( userInitiated: e.UserInitiated || ExpectDisconnection );
}
}

internal static IPacketMsg GetPacketMsg( byte[] data )
Expand Down

0 comments on commit e681328

Please sign in to comment.