aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-08 21:51:53 -0700
committerJohn Hurliman2009-10-08 21:51:53 -0700
commit56a27c37d3e84495988e423be7b52007cea595cc (patch)
tree8452b3cfbf82e00f4188a1eefadc502b042a06e3 /OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
parentFear the lockless LLUDP implementation! (diff)
downloadopensim-SC-56a27c37d3e84495988e423be7b52007cea595cc.zip
opensim-SC-56a27c37d3e84495988e423be7b52007cea595cc.tar.gz
opensim-SC-56a27c37d3e84495988e423be7b52007cea595cc.tar.bz2
opensim-SC-56a27c37d3e84495988e423be7b52007cea595cc.tar.xz
Simplified LLUDPClientCollection from three collections down to one. This will prevent any potential problems from inconsistency between the internal collections
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs46
1 files changed, 16 insertions, 30 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 1e6927f..a6aa048 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -181,22 +181,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
181 return x == m_location; 181 return x == m_location;
182 } 182 }
183 183
184 public void RemoveClient(IClientAPI client) 184 public void RemoveClient(LLUDPClient udpClient)
185 { 185 {
186 m_scene.ClientManager.Remove(client.CircuitCode); 186 m_log.Debug("[LLUDPSERVER]: Removing LLUDPClient for " + udpClient.ClientAPI.Name);
187 client.Close(false);
188 187
189 LLUDPClient udpClient; 188 m_scene.ClientManager.Remove(udpClient.CircuitCode);
190 if (clients.TryGetValue(client.AgentId, out udpClient)) 189 udpClient.ClientAPI.Close(false);
191 { 190 udpClient.Shutdown();
192 m_log.Debug("[LLUDPSERVER]: Removing LLUDPClient for " + client.Name); 191 clients.Remove(udpClient.RemoteEndPoint);
193 udpClient.Shutdown();
194 clients.Remove(client.AgentId, udpClient.RemoteEndPoint);
195 }
196 else
197 {
198 m_log.Warn("[LLUDPSERVER]: Failed to remove LLUDPClient for " + client.Name);
199 }
200 } 192 }
201 193
202 public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) 194 public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting)
@@ -230,15 +222,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
230 } 222 }
231 } 223 }
232 224
233 public void SendPacket(UUID agentID, Packet packet, ThrottleOutPacketType category, bool allowSplitting)
234 {
235 LLUDPClient client;
236 if (clients.TryGetValue(agentID, out client))
237 SendPacket(client, packet, category, allowSplitting);
238 else
239 m_log.Warn("[LLUDPSERVER]: Attempted to send a packet to unknown agentID " + agentID);
240 }
241
242 public void SendPacket(LLUDPClient client, Packet packet, ThrottleOutPacketType category, bool allowSplitting) 225 public void SendPacket(LLUDPClient client, Packet packet, ThrottleOutPacketType category, bool allowSplitting)
243 { 226 {
244 // CoarseLocationUpdate packets cannot be split in an automated way 227 // CoarseLocationUpdate packets cannot be split in an automated way
@@ -391,7 +374,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
391 { 374 {
392 m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + client.ClientAPI.Name); 375 m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + client.ClientAPI.Name);
393 376
394 RemoveClient(client.ClientAPI); 377 RemoveClient(client);
395 return; 378 return;
396 } 379 }
397 } 380 }
@@ -647,23 +630,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP
647 private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) 630 private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
648 { 631 {
649 // Create the LLUDPClient 632 // Create the LLUDPClient
650 LLUDPClient client = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); 633 LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint);
651 634
652 // Create the LLClientView 635 // Create the LLClientView
653 LLClientView clientApi = new LLClientView(remoteEndPoint, m_scene, this, client, sessionInfo, agentID, sessionID, circuitCode); 636 LLClientView clientApi = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
654 clientApi.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; 637 clientApi.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler;
655 clientApi.OnLogout += LogoutHandler; 638 clientApi.OnLogout += LogoutHandler;
656 clientApi.OnConnectionClosed += RemoveClient; 639 clientApi.OnConnectionClosed +=
640 delegate(IClientAPI client)
641 { if (client is LLClientView) RemoveClient(((LLClientView)client).UDPClient); };
657 642
658 // Start the IClientAPI 643 // Start the IClientAPI
659 m_scene.ClientManager.Add(circuitCode, clientApi); 644 m_scene.ClientManager.Add(circuitCode, clientApi);
660 clientApi.Start(); 645 clientApi.Start();
661 646
662 // Give LLUDPClient a reference to IClientAPI 647 // Give LLUDPClient a reference to IClientAPI
663 client.ClientAPI = clientApi; 648 udpClient.ClientAPI = clientApi;
664 649
665 // Add the new client to our list of tracked clients 650 // Add the new client to our list of tracked clients
666 clients.Add(agentID, client.RemoteEndPoint, client); 651 clients.Add(udpClient.RemoteEndPoint, udpClient);
667 } 652 }
668 653
669 private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend) 654 private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend)
@@ -798,7 +783,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
798 private void LogoutHandler(IClientAPI client) 783 private void LogoutHandler(IClientAPI client)
799 { 784 {
800 client.SendLogoutPacket(); 785 client.SendLogoutPacket();
801 RemoveClient(client); 786 if (client is LLClientView)
787 RemoveClient(((LLClientView)client).UDPClient);
802 } 788 }
803 } 789 }
804} 790}