Cleanup old hg sessions (older than 2 days)

cpu-performance
Diva Canto 2013-07-14 15:47:54 -07:00
parent e33ac50388
commit b0140383da
5 changed files with 20 additions and 2 deletions

View File

@ -54,5 +54,6 @@ namespace OpenSim.Data
HGTravelingData[] GetSessions(UUID userID);
bool Store(HGTravelingData data);
bool Delete(UUID sessionID);
void DeleteOld();
}
}

View File

@ -66,5 +66,15 @@ namespace OpenSim.Data.MySQL
return Delete("SessionID", sessionID.ToString());
}
public void DeleteOld()
{
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm);
ExecuteNonQuery(cmd);
}
}
}
}

View File

@ -9,6 +9,7 @@ CREATE TABLE `hg_traveling_data` (
`ServiceToken` VARCHAR(255) NOT NULL DEFAULT '',
`ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '',
`MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '',
`TMStamp` timestamp NOT NULL,
PRIMARY KEY (`SessionID`),
KEY (`UserID`)
) ENGINE=InnoDB;

View File

@ -207,6 +207,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
m_UAS = scene.RequestModuleInterface<IUserAgentService>();
if (m_UAS == null)
m_UAS = new UserAgentServiceConnector(m_ThisHomeURI);
}
}
@ -573,12 +576,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (uMan != null && uMan.IsLocalGridUser(obj.AgentId))
{
// local grid user
m_UAS.LogoutAgent(obj.AgentId, obj.SessionId);
return;
}
AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("HomeURI"))
{
string url = aCircuit.ServiceURLs["HomeURI"].ToString();
IUserAgentService security = new UserAgentServiceConnector(url);

View File

@ -148,6 +148,9 @@ namespace OpenSim.Services.HypergridService
if (!m_GridName.EndsWith("/"))
m_GridName = m_GridName + "/";
// Finally some cleanup
m_Database.DeleteOld();
}
}