aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-13 16:53:19 -0700
committerJohn Hurliman2009-10-13 16:53:19 -0700
commit395a8680c3633ca131e7481f765517311ef51710 (patch)
treee9c3634c3c37e6595b7743da88b236c12fc81422 /OpenSim
parent* Rewrote ClientManager to remove Lindenisms from OpenSim core, improve perfo... (diff)
downloadopensim-SC_OLD-395a8680c3633ca131e7481f765517311ef51710.zip
opensim-SC_OLD-395a8680c3633ca131e7481f765517311ef51710.tar.gz
opensim-SC_OLD-395a8680c3633ca131e7481f765517311ef51710.tar.bz2
opensim-SC_OLD-395a8680c3633ca131e7481f765517311ef51710.tar.xz
* Fixed a bug where clients were being added to ClientManager twice
* Changed the ClientManager interface to reduce potential errors with duplicate or mismatched keys * Added IClientAPI.RemoteEndPoint, which can (hopefully) eventually replace IClientAPI.CircuitCode * Changed the order of operations during client shutdown
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/ClientManager.cs22
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs36
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs44
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs9
5 files changed, 54 insertions, 59 deletions
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index 4edfabe..aefe425 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -97,19 +97,17 @@ namespace OpenSim.Framework
97 /// Add a client reference to the collection if it does not already 97 /// Add a client reference to the collection if it does not already
98 /// exist 98 /// exist
99 /// </summary> 99 /// </summary>
100 /// <param name="key">UUID of the client</param>
101 /// <param name="key2">Remote endpoint of the client</param>
102 /// <param name="value">Reference to the client object</param> 100 /// <param name="value">Reference to the client object</param>
103 /// <returns>True if the client reference was successfully added, 101 /// <returns>True if the client reference was successfully added,
104 /// otherwise false if the given key already existed in the collection</returns> 102 /// otherwise false if the given key already existed in the collection</returns>
105 public bool Add(UUID key, IPEndPoint key2, IClientAPI value) 103 public bool Add(IClientAPI value)
106 { 104 {
107 lock (m_writeLock) 105 lock (m_writeLock)
108 { 106 {
109 if (!m_dict.ContainsKey(key) && !m_dict2.ContainsKey(key2)) 107 if (!m_dict.ContainsKey(value.AgentId) && !m_dict2.ContainsKey(value.RemoteEndPoint))
110 { 108 {
111 m_dict = m_dict.Add(key, value); 109 m_dict = m_dict.Add(value.AgentId, value);
112 m_dict2 = m_dict2.Add(key2, value); 110 m_dict2 = m_dict2.Add(value.RemoteEndPoint, value);
113 111
114 return true; 112 return true;
115 } 113 }
@@ -123,14 +121,16 @@ namespace OpenSim.Framework
123 /// <summary> 121 /// <summary>
124 /// Remove a client from the collection 122 /// Remove a client from the collection
125 /// </summary> 123 /// </summary>
126 /// <param name="key">UUID of the client</param> 124 /// <param name="value">Reference to the client object</param>
127 /// <param name="key2">Remote endpoint of the client</param> 125 public void Remove(IClientAPI value)
128 public void Remove(UUID key, IPEndPoint key2)
129 { 126 {
130 lock (m_writeLock) 127 lock (m_writeLock)
131 { 128 {
132 m_dict = m_dict.Delete(key); 129 if (m_dict.ContainsKey(value.AgentId))
133 m_dict2 = m_dict2.Delete(key2); 130 m_dict = m_dict.Delete(value.AgentId);
131
132 if (m_dict2.ContainsKey(value.RemoteEndPoint))
133 m_dict2 = m_dict2.Delete(value.RemoteEndPoint);
134 } 134 }
135 } 135 }
136 136
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 99ea0d5..29846f5 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -561,6 +561,8 @@ namespace OpenSim.Framework
561 // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] 561 // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")]
562 uint CircuitCode { get; } 562 uint CircuitCode { get; }
563 563
564 IPEndPoint RemoteEndPoint { get; }
565
564 event GenericMessage OnGenericMessage; 566 event GenericMessage OnGenericMessage;
565 567
566 // [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")] 568 // [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")]
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 86d0112..aecb362 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -411,38 +411,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
411 "[CLIENT]: Close has been called for {0} attached to scene {1}", 411 "[CLIENT]: Close has been called for {0} attached to scene {1}",
412 Name, m_scene.RegionInfo.RegionName); 412 Name, m_scene.RegionInfo.RegionName);
413 413
414 // Remove ourselves from the scene 414 // Send the STOP packet
415 m_scene.ClientManager.Remove(m_agentId, m_udpClient.RemoteEndPoint); 415 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
416 OutPacket(disable, ThrottleOutPacketType.Unknown);
417
418 IsActive = false;
416 419
420 // Shutdown the image manager
417 if (m_imageManager != null) 421 if (m_imageManager != null)
418 {
419 m_imageManager.Close(); 422 m_imageManager.Close();
420 m_imageManager = null;
421 }
422
423 if (m_udpServer != null)
424 {
425 m_udpServer.Flush();
426 }
427 423
424 // Fire the callback for this connection closing
428 if (OnConnectionClosed != null) 425 if (OnConnectionClosed != null)
429 OnConnectionClosed(this); 426 OnConnectionClosed(this);
430 427
431 CloseCleanup(); 428 // Flush all of the packets out of the UDP server for this client
432 } 429 if (m_udpServer != null)
430 m_udpServer.Flush(m_udpClient);
433 431
434 private void CloseCleanup() 432 // Remove ourselves from the scene
435 {
436 m_scene.RemoveClient(AgentId); 433 m_scene.RemoveClient(AgentId);
434 m_scene.ClientManager.Remove(this);
437 435
438 //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 436 //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
437 //GC.Collect();
439 //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true)); 438 //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
440 439
441 // Send the STOP packet 440 // FIXME: Is this still necessary?
442 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 441 //Thread.Sleep(2000);
443 OutPacket(disable, ThrottleOutPacketType.Unknown);
444
445 Thread.Sleep(2000);
446 442
447 // Shut down timers. Thread Context of this method is murky. Lock all timers 443 // Shut down timers. Thread Context of this method is murky. Lock all timers
448 if (m_avatarTerseUpdateTimer.Enabled) 444 if (m_avatarTerseUpdateTimer.Enabled)
@@ -459,8 +455,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
459 // We need to do this over grid communications 455 // We need to do this over grid communications
460 //m_scene.CloseAllAgents(CircuitCode); 456 //m_scene.CloseAllAgents(CircuitCode);
461 457
462 IsActive = false;
463
464 m_avatarTerseUpdateTimer.Dispose(); 458 m_avatarTerseUpdateTimer.Dispose();
465 m_primTerseUpdateTimer.Dispose(); 459 m_primTerseUpdateTimer.Dispose();
466 m_primFullUpdateTimer.Dispose(); 460 m_primFullUpdateTimer.Dispose();
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
index 343f537..8469ba6 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
@@ -167,39 +167,39 @@ namespace OpenSim.Region.ClientStack.LindenUDP
167 J2KImage imagereq; 167 J2KImage imagereq;
168 int numCollected = 0; 168 int numCollected = 0;
169 169
170 //lock (m_syncRoot) 170 m_lastloopprocessed = DateTime.Now.Ticks;
171 //{ 171
172 m_lastloopprocessed = DateTime.Now.Ticks; 172 // This can happen during Close()
173 173 if (m_client == null)
174 // This can happen during Close() 174 return false;
175 if (m_client == null) 175
176 return false; 176 while ((imagereq = GetHighestPriorityImage()) != null)
177 177 {
178 while ((imagereq = GetHighestPriorityImage()) != null) 178 if (imagereq.IsDecoded == true)
179 { 179 {
180 if (imagereq.IsDecoded == true) 180 ++numCollected;
181 {
182 ++numCollected;
183 181
184 if (imagereq.SendPackets(m_client, maxpack)) 182 if (imagereq.SendPackets(m_client, maxpack))
185 { 183 {
186 // Send complete. Destroy any knowledge of this transfer 184 // Send complete. Destroy any knowledge of this transfer
187 RemoveImageFromQueue(imagereq); 185 RemoveImageFromQueue(imagereq);
188 }
189 } 186 }
190
191 if (numCollected == count)
192 break;
193 } 187 }
194 //} 188
189 if (numCollected == count)
190 break;
191 }
195 192
196 return m_priorityQueue.Count > 0; 193 return m_priorityQueue.Count > 0;
197 } 194 }
198 195
199 //Faux destructor 196 /// <summary>
197 /// Faux destructor
198 /// </summary>
200 public void Close() 199 public void Close()
201 { 200 {
202 m_shuttingdown = true; 201 m_shuttingdown = true;
202 m_priorityQueue = null;
203 m_j2kDecodeModule = null; 203 m_j2kDecodeModule = null;
204 m_assetCache = null; 204 m_assetCache = null;
205 m_client = null; 205 m_client = null;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 8ec143a..22c275c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -390,7 +390,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
390 } 390 }
391 } 391 }
392 392
393 public void Flush() 393 public void Flush(LLUDPClient udpClient)
394 { 394 {
395 // FIXME: Implement? 395 // FIXME: Implement?
396 } 396 }
@@ -645,15 +645,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
645 client.OnLogout += LogoutHandler; 645 client.OnLogout += LogoutHandler;
646 client.OnConnectionClosed += ConnectionClosedHandler; 646 client.OnConnectionClosed += ConnectionClosedHandler;
647 647
648 m_scene.ClientManager.Add(agentID, remoteEndPoint, client);
649
650 // Start the IClientAPI 648 // Start the IClientAPI
651 m_scene.ClientManager.Add(agentID, remoteEndPoint, client); 649 m_scene.ClientManager.Add(client);
652 client.Start(); 650 client.Start();
653 } 651 }
654 else 652 else
655 { 653 {
656 m_log.Debug("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from " + udpClient.AgentID); 654 m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
655 udpClient.AgentID, remoteEndPoint, circuitCode);
657 } 656 }
658 } 657 }
659 658