Instead of retrieving the known client again in LLUDPServer.RemoveClient(), check the IsLoggingOut flag instead.

This is slightly better thread-race wise
0.7.4.1
Justin Clark-Casey (justincc) 2012-06-08 04:12:22 +01:00
parent c215b1ad16
commit f94b92df46
1 changed files with 10 additions and 21 deletions

View File

@ -560,7 +560,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
RemoveClient(udpClient); RemoveClient(client);
return; return;
} }
@ -1110,11 +1110,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return client; return client;
} }
private void RemoveClient(LLUDPClient udpClient) private void RemoveClient(IClientAPI client)
{
// Remove this client from the scene
IClientAPI client;
if (m_scene.TryGetClient(udpClient.AgentID, out client))
{ {
// We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method. // We must set IsLoggingOut synchronously so that we can stop the packet loop reinvoking this method.
client.IsLoggingOut = true; client.IsLoggingOut = true;
@ -1124,13 +1120,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// This is the same as processing as the async process of a logout request. // This is the same as processing as the async process of a logout request.
Util.FireAndForget(o => client.Close()); Util.FireAndForget(o => client.Close());
} }
else
{
m_log.WarnFormat(
"[LLUDPSERVER]: Tried to remove client with id {0} but not such client in {1}",
udpClient.AgentID, m_scene.RegionInfo.RegionName);
}
}
private void IncomingPacketHandler() private void IncomingPacketHandler()
{ {
@ -1443,8 +1432,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected void LogoutHandler(IClientAPI client) protected void LogoutHandler(IClientAPI client)
{ {
client.SendLogoutPacket(); client.SendLogoutPacket();
if (client.IsActive) if (!client.IsLoggingOut)
RemoveClient(((LLClientView)client).UDPClient); RemoveClient(client);
} }
} }
} }