From 78f831ef5220907e4d50422a5422063921062cf8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 7 Sep 2008 03:22:33 +0000 Subject: * minor: Clean up of logging messages to make following the client login process easier * documentation --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 22 ++++++-- .../Region/ClientStack/LindenUDP/LLPacketServer.cs | 42 +++++++++++--- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 66 ++++++++++++++-------- 3 files changed, 93 insertions(+), 37 deletions(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 5e22e2d..b721fa3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -376,6 +376,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP /* METHODS */ + /// + /// Constructor + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// public LLClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, LLPacketServer packServer, AgentCircuitManager authenSessions, UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP) { @@ -417,7 +429,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_clientThread.Start(); ThreadTracker.Add(m_clientThread); - m_log.Info("[CLIENT]: Started up new thread to handle client UDP session"); + m_log.DebugFormat("[CLIENT]: Started new UDP session thread for agent {0}, circuit {1}", agentId, circuitCode); } public void SetDebug(int newDebug) @@ -634,7 +646,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected virtual void ClientLoop() { - m_log.Info("[CLIENT]: Entered loop"); + m_log.Info("[CLIENT]: Entered main packet processing loop"); + while (true) { LLQueItem nextPacket = m_PacketHandler.PacketQueue.Dequeue(); @@ -729,7 +742,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected virtual void AuthUser() { - //tell this thread we are using the culture set up for the sim (currently hardcoded to en_US) //otherwise it will override this and use the system default Culture.SetCurrentCulture(); @@ -738,8 +750,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(m_cirpack.m_circuitCode.m_sessionId, m_cirpack.m_circuitCode.ID, m_cirpack.m_circuitCode.Code); AuthenticateResponse sessionInfo = - m_authenticateSessionsHandler.AuthenticateSession(m_sessionId, m_agentId, - m_circuitCode); + m_authenticateSessionsHandler.AuthenticateSession(m_sessionId, m_agentId, m_circuitCode); + if (!sessionInfo.Authorised) { //session/circuit not authorised diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs index 07d3c45..c36a238 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs @@ -70,17 +70,43 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_scene.ClientManager.InPacket(circuitCode, packet); } - protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, - ClientManager clientManager, IScene scene, AssetCache assetCache, - LLPacketServer packServer, AgentCircuitManager authenSessions, - UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP) + /// + /// Create a new client circuit + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + protected virtual IClientAPI CreateNewCircuit(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, + ClientManager clientManager, IScene scene, AssetCache assetCache, + LLPacketServer packServer, AgentCircuitManager authenSessions, + UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP) { return new LLClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP); } + /// + /// Add a new client circuit + /// + /// + /// + /// + /// + /// + /// + /// true if a new circuit was created, false if a circuit with the given circuit code already existed + /// public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, - AgentCircuitManager authenticateSessionsClass, EndPoint proxyEP) + AgentCircuitManager circuitManager, EndPoint proxyEP) { IClientAPI newuser; @@ -90,9 +116,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { - newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, - authenticateSessionsClass, useCircuit.CircuitCode.ID, - useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code, proxyEP); + newuser = CreateNewCircuit(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, + circuitManager, useCircuit.CircuitCode.ID, + useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code, proxyEP); m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index ceb99ae..5625854 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -75,7 +75,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); protected IScene m_localScene; protected AssetCache m_assetCache; - protected AgentCircuitManager m_authenticateSessionsClass; + + /// + /// Manages authentication for agent circuits + /// + protected AgentCircuitManager m_circuitManager; public LLPacketServer PacketServer { @@ -132,14 +136,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, assetCache, authenticateClass); } - public void Initialise(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass) + /// + /// Initialize the server + /// + /// + /// + /// + /// + /// + /// + public void Initialise( + IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager circuitManager) { this.proxyPortOffset = proxyPortOffset; listenPort = (uint) (port + proxyPortOffset); listenIP = _listenIP; Allow_Alternate_Port = allow_alternate_port; m_assetCache = assetCache; - m_authenticateSessionsClass = authenticateClass; + m_circuitManager = circuitManager; CreatePacketServer(); // Return new port @@ -177,7 +191,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { // TODO : Actually only handle those states that we have control over, re-throw everything else, // TODO: implement cases as we encounter them. - //m_log.Error("[UDPSERVER]: Connection Error! - " + e.ToString()); + //m_log.Error("[[CLIENT]: ]: Connection Error! - " + e.ToString()); switch (e.SocketErrorCode) { case SocketError.AlreadyInProgress: @@ -193,7 +207,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } catch (ObjectDisposedException e) { - m_log.DebugFormat("ObjectDisposedException: Object {0} disposed.", e.ObjectName); + m_log.DebugFormat("[CLIENT]: ObjectDisposedException: Object {0} disposed.", e.ObjectName); // Uhh, what object, and why? this needs better handling. } @@ -213,15 +227,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP } catch (MalformedDataException e) { - m_log.DebugFormat("Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace); + m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace); } catch (IndexOutOfRangeException e) { - m_log.DebugFormat("Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace); + m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace); } catch (Exception e) { - m_log.Debug("[UDPSERVER]: " + e.ToString()); + m_log.Debug("[CLIENT]: " + e.ToString()); } } @@ -249,8 +263,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else if (packet.Type == PacketType.UseCircuitCode) { - // new client - m_log.Debug("[UDPSERVER]: Adding New Client"); AddNewClient(packet); UseCircuitCodePacket p = (UseCircuitCodePacket)packet; @@ -267,7 +279,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } catch (Exception e) { - m_log.Error("[UDPSERVER]: Exception in processing packet - ignoring: ", e); + m_log.Error("[CLIENT]: Exception in processing packet - ignoring: ", e); } } } @@ -280,7 +292,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } catch (SocketException e) { - m_log.ErrorFormat("[UDPSERVER]: BeginRecieve threw exception " + e.Message + ": " + e.StackTrace ); + m_log.ErrorFormat("[CLIENT]: BeginRecieve threw exception " + e.Message + ": " + e.StackTrace ); ResetEndPoint(); } } @@ -339,19 +351,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; + + m_log.DebugFormat("[CLIENT]: Adding new circuit for agent {0}, circuit code {1}", useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code); + lock (clientCircuits) { if (!clientCircuits.ContainsKey(epSender)) clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); else - m_log.Error("[UDPSERVER]: clientCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); + m_log.Error("[CLIENT]: clientCircuits already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); } // This doesn't need locking as it's synchronized data if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); else - m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); + m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); lock (proxyCircuits) @@ -359,10 +374,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy); else - m_log.Error("[UDPSERVER]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); + m_log.Error("[CLIENT]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); } - PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass, epProxy); + if (!PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_circuitManager, epProxy)) + m_log.ErrorFormat( + "[CLIENT]: A circuit already existed for agent {0}, circuit {1}", + useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code); } PacketPool.Instance.ReturnPacket(packet); @@ -371,7 +389,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void ServerListener() { uint newPort = listenPort; - m_log.Info("[SERVER]: Opening UDP socket on " + listenIP + " " + newPort + "."); + m_log.Info("[UDPSERVER]: Opening UDP socket on " + listenIP + " " + newPort + "."); ServerIncoming = new IPEndPoint(listenIP, (int)newPort); m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); @@ -385,14 +403,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP listenPort = newPort; - m_log.Info("[SERVER]: UDP socket bound, getting ready to listen"); + m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen"); ipeSender = new IPEndPoint(listenIP, 0); epSender = (EndPoint)ipeSender; ReceivedData = new AsyncCallback(OnReceivedData); m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - m_log.Info("[SERVER]: Listening on port " + newPort); + m_log.Info("[UDPSERVER]: Listening on port " + newPort); } public virtual void RegisterPacketServer(LLPacketServer server) @@ -409,7 +427,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP sendto = (EndPoint)clientCircuits_reverse[circuitcode]; } catch { // Exceptions here mean there is no circuit - m_log.Warn("Circuit not found, not sending packet"); + m_log.Warn("[CLIENT]: Circuit not found, not sending packet"); return; } @@ -448,7 +466,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP else { m_log.DebugFormat( - "[UDPSERVER]: endpoint for circuit code {0} in RemoveClientCircuit() was unexpectedly null!", circuitcode); + "[CLIENT]: endpoint for circuit code {0} in RemoveClientCircuit() was unexpectedly null!", circuitcode); } } lock (proxyCircuits) @@ -472,14 +490,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!clientCircuits.ContainsKey(userEP)) clientCircuits.Add(userEP, useCircuit.CircuitCode.Code); else - m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); + m_log.Error("[CLIENT]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); } // This data structure is synchronized, so we don't need the lock if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP); else - m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); + m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); lock (proxyCircuits) { @@ -495,7 +513,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_authenticateSessionsClass, proxyEP); + PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_circuitManager, proxyEP); } } } -- cgit v1.1