aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-13 11:28:08 -0700
committerJohn Hurliman2009-10-13 11:28:08 -0700
commitf55b282078e4e7c5ee7d0ca613891302d2b9957d (patch)
tree7d536881802a7ab35fb100ac5894e2b1bd74c72c /OpenSim/Region
parent* Broke the circular reference between LLClientView and LLUDPClient. This sho... (diff)
downloadopensim-SC_OLD-f55b282078e4e7c5ee7d0ca613891302d2b9957d.zip
opensim-SC_OLD-f55b282078e4e7c5ee7d0ca613891302d2b9957d.tar.gz
opensim-SC_OLD-f55b282078e4e7c5ee7d0ca613891302d2b9957d.tar.bz2
opensim-SC_OLD-f55b282078e4e7c5ee7d0ca613891302d2b9957d.tar.xz
Avoid checking m_clients collection twice when a UseCircuitCode packet is received
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs2
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs56
2 files changed, 30 insertions, 28 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs
index 2972d46..4f375e4 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs
@@ -131,7 +131,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
131 /// <param name="action">Action to perform on each element</param> 131 /// <param name="action">Action to perform on each element</param>
132 public void ForEach(Action<LLUDPClient> action) 132 public void ForEach(Action<LLUDPClient> action)
133 { 133 {
134 Parallel.ForEach<LLUDPClient>(m_dict.Values, action); 134 Parallel.ForEach<LLUDPClient>(m_dict.Values, action);
135 } 135 }
136 } 136 }
137} 137}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 0b5b51d..2228f39 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -503,19 +503,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
503 503
504 #endregion Decoding 504 #endregion Decoding
505 505
506 #region UseCircuitCode Handling 506 #region Packet to Client Mapping
507 507
508 // UseCircuitCode handling
508 if (packet.Type == PacketType.UseCircuitCode) 509 if (packet.Type == PacketType.UseCircuitCode)
509 { 510 {
510 UseCircuitCodePacket useCircuitCode = (UseCircuitCodePacket)packet; 511 AddNewClient((UseCircuitCodePacket)packet, (IPEndPoint)buffer.RemoteEndPoint);
511 IClientAPI newuser;
512 uint circuitCode = useCircuitCode.CircuitCode.Code;
513
514 // Check if the client is already established
515 if (!m_scene.ClientManager.TryGetClient(circuitCode, out newuser))
516 {
517 AddNewClient(useCircuitCode, (IPEndPoint)buffer.RemoteEndPoint);
518 }
519 } 512 }
520 513
521 // Determine which agent this packet came from 514 // Determine which agent this packet came from
@@ -526,7 +519,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
526 return; 519 return;
527 } 520 }
528 521
529 #endregion UseCircuitCode Handling 522 #endregion Packet to Client Mapping
530 523
531 // Stats tracking 524 // Stats tracking
532 Interlocked.Increment(ref client.PacketsReceived); 525 Interlocked.Increment(ref client.PacketsReceived);
@@ -620,29 +613,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
620 613
621 private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint) 614 private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
622 { 615 {
623 //Slave regions don't accept new clients
624 if (m_scene.RegionStatus != RegionStatus.SlaveScene) 616 if (m_scene.RegionStatus != RegionStatus.SlaveScene)
625 { 617 {
626 AuthenticateResponse sessionInfo; 618 if (!m_clients.ContainsKey(remoteEndPoint))
627 bool isNewCircuit = !m_clients.ContainsKey(remoteEndPoint);
628
629 if (!IsClientAuthorized(useCircuitCode, out sessionInfo))
630 { 619 {
631 m_log.WarnFormat( 620 AuthenticateResponse sessionInfo;
632 "[CONNECTION FAILURE]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", 621 if (IsClientAuthorized(useCircuitCode, out sessionInfo))
633 useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint); 622 {
634 return; 623 UUID agentID = useCircuitCode.CircuitCode.ID;
635 } 624 UUID sessionID = useCircuitCode.CircuitCode.SessionID;
625 uint circuitCode = useCircuitCode.CircuitCode.Code;
636 626
637 if (isNewCircuit) 627 AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
628 }
629 else
630 {
631 // Don't create circuits for unauthorized clients
632 m_log.WarnFormat(
633 "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}",
634 useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint);
635 }
636 }
637 else
638 { 638 {
639 UUID agentID = useCircuitCode.CircuitCode.ID; 639 // Ignore repeated UseCircuitCode packets
640 UUID sessionID = useCircuitCode.CircuitCode.SessionID; 640 m_log.Debug("[LLUDPSERVER]: Ignoring UseCircuitCode for already established circuit " + useCircuitCode.CircuitCode.Code);
641 uint circuitCode = useCircuitCode.CircuitCode.Code;
642
643 AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo);
644 } 641 }
645 } 642 }
643 else
644 {
645 // Slave regions don't accept new clients
646 m_log.Debug("[LLUDPSERVER]: Slave region " + m_scene.RegionInfo.RegionName + " ignoring UseCircuitCode packet");
647 }
646 } 648 }
647 649
648 private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) 650 private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)