Avoid checking m_clients collection twice when a UseCircuitCode packet is received
parent
82ace481c9
commit
f55b282078
|
@ -503,19 +503,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
#endregion Decoding
|
#endregion Decoding
|
||||||
|
|
||||||
#region UseCircuitCode Handling
|
#region Packet to Client Mapping
|
||||||
|
|
||||||
|
// UseCircuitCode handling
|
||||||
if (packet.Type == PacketType.UseCircuitCode)
|
if (packet.Type == PacketType.UseCircuitCode)
|
||||||
{
|
{
|
||||||
UseCircuitCodePacket useCircuitCode = (UseCircuitCodePacket)packet;
|
AddNewClient((UseCircuitCodePacket)packet, (IPEndPoint)buffer.RemoteEndPoint);
|
||||||
IClientAPI newuser;
|
|
||||||
uint circuitCode = useCircuitCode.CircuitCode.Code;
|
|
||||||
|
|
||||||
// Check if the client is already established
|
|
||||||
if (!m_scene.ClientManager.TryGetClient(circuitCode, out newuser))
|
|
||||||
{
|
|
||||||
AddNewClient(useCircuitCode, (IPEndPoint)buffer.RemoteEndPoint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine which agent this packet came from
|
// Determine which agent this packet came from
|
||||||
|
@ -526,7 +519,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion UseCircuitCode Handling
|
#endregion Packet to Client Mapping
|
||||||
|
|
||||||
// Stats tracking
|
// Stats tracking
|
||||||
Interlocked.Increment(ref client.PacketsReceived);
|
Interlocked.Increment(ref client.PacketsReceived);
|
||||||
|
@ -620,29 +613,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
|
private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
|
||||||
{
|
{
|
||||||
//Slave regions don't accept new clients
|
|
||||||
if (m_scene.RegionStatus != RegionStatus.SlaveScene)
|
if (m_scene.RegionStatus != RegionStatus.SlaveScene)
|
||||||
{
|
{
|
||||||
AuthenticateResponse sessionInfo;
|
if (!m_clients.ContainsKey(remoteEndPoint))
|
||||||
bool isNewCircuit = !m_clients.ContainsKey(remoteEndPoint);
|
|
||||||
|
|
||||||
if (!IsClientAuthorized(useCircuitCode, out sessionInfo))
|
|
||||||
{
|
{
|
||||||
m_log.WarnFormat(
|
AuthenticateResponse sessionInfo;
|
||||||
"[CONNECTION FAILURE]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
|
if (IsClientAuthorized(useCircuitCode, out sessionInfo))
|
||||||
useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint);
|
{
|
||||||
return;
|
UUID agentID = useCircuitCode.CircuitCode.ID;
|
||||||
}
|
UUID sessionID = useCircuitCode.CircuitCode.SessionID;
|
||||||
|
uint circuitCode = useCircuitCode.CircuitCode.Code;
|
||||||
|
|
||||||
if (isNewCircuit)
|
AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Don't create circuits for unauthorized clients
|
||||||
|
m_log.WarnFormat(
|
||||||
|
"[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
|
||||||
|
useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
UUID agentID = useCircuitCode.CircuitCode.ID;
|
// Ignore repeated UseCircuitCode packets
|
||||||
UUID sessionID = useCircuitCode.CircuitCode.SessionID;
|
m_log.Debug("[LLUDPSERVER]: Ignoring UseCircuitCode for already established circuit " + useCircuitCode.CircuitCode.Code);
|
||||||
uint circuitCode = useCircuitCode.CircuitCode.Code;
|
|
||||||
|
|
||||||
AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Slave regions don't accept new clients
|
||||||
|
m_log.Debug("[LLUDPSERVER]: Slave region " + m_scene.RegionInfo.RegionName + " ignoring UseCircuitCode packet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
|
private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
|
||||||
|
|
Loading…
Reference in New Issue