From e7170496becbdcd79b6a40d37fb88e050173ebe2 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 17 Dec 2007 16:39:11 +0000 Subject: Thank you, Kiryu for a patch to fix out of sync error in UDP server in the file UDPServer.cs. Submitted by Jeff Ames via Mantis#200 --- OpenSim/Region/ClientStack/UDPServer.cs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 2190fbf..55ef4a4 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -39,6 +39,7 @@ namespace OpenSim.Region.ClientStack public class UDPServer : ClientStackNetworkHandler { protected Dictionary clientCircuits = new Dictionary(); + protected Dictionary clientCircuits_reverse = new Dictionary(); public Socket Server; protected IPEndPoint ServerIncoming; protected byte[] RecvBuffer = new byte[4096]; @@ -176,6 +177,7 @@ namespace OpenSim.Region.ClientStack { UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); + clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); } @@ -208,15 +210,7 @@ namespace OpenSim.Region.ClientStack { // find the endpoint for this circuit EndPoint sendto = null; - foreach (KeyValuePair p in clientCircuits) - { - if (p.Value == circuitcode) - { - sendto = p.Key; - break; - } - } - if (sendto != null) + if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) { //we found the endpoint so send the packet to it Server.SendTo(buffer, size, flags, sendto); @@ -225,13 +219,11 @@ namespace OpenSim.Region.ClientStack public virtual void RemoveClientCircuit(uint circuitcode) { - foreach (KeyValuePair p in clientCircuits) + EndPoint sendto = null; + if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) { - if (p.Value == circuitcode) - { - clientCircuits.Remove(p.Key); - break; - } + clientCircuits.Remove(sendto); + clientCircuits_reverse.Remove(circuitcode); } } } -- cgit v1.1