Store already retrieve IClientAPI in IncomingPacket structure for later use rather than doing another retrieve on dequeue.

Instead of checking whether the client still exists by trying to retrieve again from the client manager, this patch gets it back from IncomingPacket and checks the IClientAPI.IsActive state.
0.7.4.1
Justin Clark-Casey (justincc) 2012-06-08 01:43:58 +01:00
parent 30f4a33f01
commit d71c6dea7e
2 changed files with 16 additions and 15 deletions

View File

@ -39,7 +39,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public sealed class IncomingPacket public sealed class IncomingPacket
{ {
/// <summary>Client this packet came from</summary> /// <summary>Client this packet came from</summary>
public LLUDPClient Client; public LLClientView Client;
/// <summary>Packet data that has been received</summary> /// <summary>Packet data that has been received</summary>
public Packet Packet; public Packet Packet;
@ -48,7 +49,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// </summary> /// </summary>
/// <param name="client">Reference to the client this packet came from</param> /// <param name="client">Reference to the client this packet came from</param>
/// <param name="packet">Packet data</param> /// <param name="packet">Packet data</param>
public IncomingPacket(LLUDPClient client, Packet packet) public IncomingPacket(LLClientView client, Packet packet)
{ {
Client = client; Client = client;
Packet = packet; Packet = packet;

View File

@ -879,7 +879,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion Ping Check Handling #endregion Ping Check Handling
// Inbox insertion // Inbox insertion
packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet));
} }
#region BinaryStats #region BinaryStats
@ -1386,22 +1386,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion #endregion
private void ProcessInPacket(object state) private void ProcessInPacket(IncomingPacket incomingPacket)
{ {
IncomingPacket incomingPacket = (IncomingPacket)state;
Packet packet = incomingPacket.Packet; Packet packet = incomingPacket.Packet;
LLUDPClient udpClient = incomingPacket.Client; LLClientView client = incomingPacket.Client;
IClientAPI client;
// Sanity check // Sanity check
if (packet == null || udpClient == null) if (packet == null || client == null)
{ {
m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", UDPClient=\"{1}\"", m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", Client=\"{1}\"",
packet, udpClient); packet, client);
} }
// Make sure this client is still alive if (client.IsActive)
if (m_scene.TryGetClient(udpClient.AgentID, out client))
{ {
m_currentIncomingClient = client; m_currentIncomingClient = client;
@ -1419,8 +1416,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
catch (Exception e) catch (Exception e)
{ {
// Don't let a failure in an individual client thread crash the whole sim. // Don't let a failure in an individual client thread crash the whole sim.
m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type); m_log.Error(
m_log.Error(e.Message, e); string.Format(
"[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw ",
client.Name, packet.Type),
e);
} }
finally finally
{ {
@ -1431,7 +1431,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
m_log.DebugFormat( m_log.DebugFormat(
"[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
packet.Type, udpClient.AgentID, m_scene.RegionInfo.RegionName); packet.Type, client.Name, m_scene.RegionInfo.RegionName);
} }
} }