From 815278531ab578dc5c4fbfefb71c6b458c201571 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 7 Sep 2008 05:07:57 +0000 Subject: * Improve login failure handling. * Now it should properly inform the user and stop a login if a region server could not be contacted in order to expect a user (the last commit didn't actually quite work correctly) --- OpenSim/Framework/Communications/LoginService.cs | 41 +++++++++++----------- OpenSim/Grid/UserServer/UserLoginService.cs | 31 +++++++--------- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 -- .../Communications/Local/LocalLoginService.cs | 6 ++-- .../Region/Communications/OGS1/OGS1GridServices.cs | 1 + 5 files changed, 38 insertions(+), 43 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index d8d0fa2..42292f3 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -74,11 +74,13 @@ namespace OpenSim.Framework.Communications } /// - /// Customises the login response and fills in missing values. + /// Customises the login response and fills in missing values. This method also tells the login region to + /// expect a client connection. /// /// The existing response /// The user profile - public abstract void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); + /// true on success, false if the region was not successfully told to expect a user connection + public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest); /// /// If the user is already logged in, try to notify the region that the user they've got is dead. @@ -86,8 +88,8 @@ namespace OpenSim.Framework.Communications /// public virtual void LogOffUser(UserProfileData theUser, string message) { - } + /// /// Get the initial login inventory skeleton (in other words, the folder structure) for the given user. /// @@ -284,29 +286,26 @@ namespace OpenSim.Framework.Communications logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); logResponse.StartLocation = startLocationRequest; - try + if (CustomiseResponse(logResponse, userProfile, startLocationRequest)) { - CustomiseResponse(logResponse, userProfile, startLocationRequest); + userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; + CommitAgent(ref userProfile); + + // If we reach this point, then the login has successfully logged onto the grid + if (StatsManager.UserStats != null) + StatsManager.UserStats.AddSuccessfulLogin(); + + m_log.DebugFormat( + "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", + firstname, lastname); + + return logResponse.ToXmlRpcResponse(); } - catch (Exception e) + else { - m_log.Info("[LOGIN END]: XMLRPC " + e.ToString()); + m_log.ErrorFormat("[LOGIN END]: XMLRPC informing user {0} {1} that login failed due to an unavailable region", firstname, lastname); return logResponse.CreateDeadRegionResponse(); - //return logResponse.ToXmlRpcResponse(); } - - userProfile.LastLogin = userProfile.CurrentAgent.LoginTime; - CommitAgent(ref userProfile); - - // If we reach this point, then the login has successfully logged onto the grid - if (StatsManager.UserStats != null) - StatsManager.UserStats.AddSuccessfulLogin(); - - m_log.DebugFormat( - "[LOGIN END]: XMLRPC Authentication of user {0} {1} successful. Sending response to client.", - firstname, lastname); - - return logResponse.ToXmlRpcResponse(); } catch (Exception e) { diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 8683daf..bd0e38b 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -97,8 +97,6 @@ namespace OpenSim.Grid.UserServer ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); - // Update agent with target sim - m_log.InfoFormat( "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, @@ -124,18 +122,13 @@ namespace OpenSim.Grid.UserServer //base.LogOffUser(theUser); } - //public override void LogOffUser(UserProfileData theUser) - //{ - - //} - /// /// Customises the login response and fills in missing values. /// /// The existing response /// The user profile /// Destination of the user - public override void CustomiseResponse(LoginResponse response, UserProfileData theUser, + public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) { RegionProfileData SimInfo; @@ -250,8 +243,7 @@ namespace OpenSim.Grid.UserServer ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong) m_config.DefaultY * Constants.RegionSize); - m_log.Warn( - "[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); SimInfo = RegionProfileData.RequestSimProfileData( defaultHandle, m_config.GridServerURL, @@ -267,8 +259,13 @@ namespace OpenSim.Grid.UserServer theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); if (!PrepareLoginToRegion(SimInfo, theUser, response)) + { response.CreateDeadRegionResponse(); + return false; + } } + + return true; } /// @@ -282,10 +279,7 @@ namespace OpenSim.Grid.UserServer private bool PrepareLoginToRegion(RegionProfileData sim, UserProfileData user, LoginResponse response) { try - { - // Destination - m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + sim.regionLocX + "; Region Y: " + sim.regionLocY); - + { response.SimAddress = Util.GetHostFromURL(sim.serverURI).ToString(); response.SimPort = uint.Parse(sim.serverURI.Split(new char[] {'/', ':'})[4]); response.RegionX = sim.regionLocX; @@ -296,7 +290,9 @@ namespace OpenSim.Grid.UserServer response.SeedCapability = sim.httpServerURI + "CAPS/" + capsPath + "0000/"; // Notify the target of an incoming user - m_log.Info("[LOGIN]: Telling " + sim.regionName + " (" + sim.serverURI + ") to prepare for client connection"); + m_log.InfoFormat( + "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", + sim.regionName, sim.regionLocX, sim.regionLocY, sim.serverURI); // Update agent with target sim user.CurrentAgent.Region = sim.UUID; @@ -317,8 +313,6 @@ namespace OpenSim.Grid.UserServer SimParams["caps_path"] = capsPath; ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); - - m_log.Info("[LOGIN]: Informing region at " + sim.httpServerURI); // Send XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); @@ -345,7 +339,6 @@ namespace OpenSim.Grid.UserServer handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; if (handlerUserLoggedInAtLocation != null) { - m_log.Info("[LOGIN]: Letting listeners know about successful login"); handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID, user.CurrentAgent.Region, user.CurrentAgent.Handle, @@ -357,11 +350,13 @@ namespace OpenSim.Grid.UserServer } else { + m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients"); return false; } } else { + m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode); return false; } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b721fa3..356dee8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -428,8 +428,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_clientThread.IsBackground = true; m_clientThread.Start(); ThreadTracker.Add(m_clientThread); - - m_log.DebugFormat("[CLIENT]: Started new UDP session thread for agent {0}, circuit {1}", agentId, circuitCode); } public void SetDebug(int newDebug) diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 518ba09..7b93bfb 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -122,7 +122,7 @@ namespace OpenSim.Region.Communications.Local private Regex reURI = new Regex(@"^uri:(?[^&]+)&(?\d+)&(?\d+)&(?\d+)$"); - public override void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) + public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) { ulong currentRegion = 0; @@ -145,7 +145,6 @@ namespace OpenSim.Region.Communications.Local { currentRegion = theUser.HomeRegion; response.StartLocation = "home"; - } else { @@ -264,7 +263,10 @@ namespace OpenSim.Region.Communications.Local else { m_log.Warn("[LOGIN]: Not found region " + currentRegion); + return false; } + + return true; } private LoginResponse.BuddyList ConvertFriendListItem(List LFL) diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 4443de9..aaeca4b 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -89,6 +89,7 @@ namespace OpenSim.Region.Communications.OGS1 { serversInfo = servers_info; httpServer = httpServe; + //Respond to Grid Services requests httpServer.AddXmlRPCHandler("expect_user", ExpectUser); httpServer.AddXmlRPCHandler("logoff_user", LogOffUser); -- cgit v1.1