Add "image queues clear <first-name> <last-name>" console command

This allows a way to manually clear pending image queue requests for debug purposes
iar_mods
Justin Clark-Casey (justincc) 2012-01-19 19:49:06 +00:00
parent d75899f2d1
commit c92a9a6640
2 changed files with 80 additions and 15 deletions

View File

@ -245,6 +245,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_shuttingdown = true; m_shuttingdown = true;
} }
/// <summary>
/// Clear the image queue.
/// </summary>
/// <returns>The number of requests cleared.</returns>
public int ClearImageQueue()
{
int requestsDeleted;
lock (m_priorityQueue)
{
requestsDeleted = m_priorityQueue.Count;
// Surprisingly, there doesn't seem to be a clear method at this time.
while (!m_priorityQueue.IsEmpty)
m_priorityQueue.DeleteMax();
}
return requestsDeleted;
}
/// <summary> /// <summary>
/// Returns an array containing all the images in the queue. /// Returns an array containing all the images in the queue.
/// </summary> /// </summary>

View File

@ -79,7 +79,19 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
lock (m_scenes) lock (m_scenes)
m_scenes[scene.RegionInfo.RegionID] = scene; m_scenes[scene.RegionInfo.RegionID] = scene;
scene.AddCommand(
this, "image queues clear",
"image queues clear <first-name> <last-name>",
"Clear the image queues (textures downloaded via UDP) for a particular client.",
(mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd)));
scene.AddCommand(
this, "show image queues",
"image queues show <first-name> <last-name>",
"Show the image queues (textures downloaded via UDP) for a particular client.",
(mod, cmd) => MainConsole.Instance.Output(GetImageQueuesReport(cmd)));
scene.AddCommand( scene.AddCommand(
this, "show pqueues", this, "show pqueues",
@ -116,7 +128,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
"emergency-monitoring", "emergency-monitoring",
"Go on/off emergency monitoring mode", "Go on/off emergency monitoring mode",
"Go on/off emergency monitoring mode", "Go on/off emergency monitoring mode",
EmergencyMonitoring); HandleEmergencyMonitoring);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -132,7 +144,49 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
} }
protected void EmergencyMonitoring(string module, string[] cmd) protected string HandleImageQueuesClear(string[] cmd)
{
if (cmd.Length != 5)
return "Usage: image queues clear <first-name> <last-name>";
string firstName = cmd[3];
string lastName = cmd[4];
List<ScenePresence> foundAgents = new List<ScenePresence>();
lock (m_scenes)
{
foreach (Scene scene in m_scenes.Values)
{
ScenePresence sp = scene.GetScenePresence(firstName, lastName);
if (sp != null)
foundAgents.Add(sp);
}
}
if (foundAgents.Count == 0)
return string.Format("No agents found for {0} {1}", firstName, lastName);
StringBuilder report = new StringBuilder();
foreach (ScenePresence agent in foundAgents)
{
LLClientView client = agent.ControllingClient as LLClientView;
if (client == null)
return "This command is only supported for LLClientView";
int requestsDeleted = client.ImageManager.ClearImageQueue();
report.AppendFormat(
"In region {0} ({1} agent) cleared {2} requests\n",
agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root", requestsDeleted);
}
return report.ToString();
}
protected void HandleEmergencyMonitoring(string module, string[] cmd)
{ {
bool mode = true; bool mode = true;
if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on")) if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
@ -239,10 +293,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
private string GetImageQueuesReport(string[] showParams) private string GetImageQueuesReport(string[] showParams)
{ {
if (showParams.Length < 5 || showParams.Length > 6) if (showParams.Length < 5 || showParams.Length > 6)
{ return "Usage: show image queues <first-name> <last-name> [full]";
MainConsole.Instance.OutputFormat("Usage: show image queues <first-name> <last-name> [full]");
return "";
}
string firstName = showParams[3]; string firstName = showParams[3];
string lastName = showParams[4]; string lastName = showParams[4];
@ -262,10 +313,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
} }
if (foundAgents.Count == 0) if (foundAgents.Count == 0)
{ return string.Format("No agents found for {0} {1}", firstName, lastName);
MainConsole.Instance.OutputFormat("No agents found for {0} {1}", firstName, lastName);
return "";
}
StringBuilder report = new StringBuilder(); StringBuilder report = new StringBuilder();
@ -274,10 +322,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden
LLClientView client = agent.ControllingClient as LLClientView; LLClientView client = agent.ControllingClient as LLClientView;
if (client == null) if (client == null)
{ return "This command is only supported for LLClientView";
MainConsole.Instance.OutputFormat("This command is only supported for LLClientView");
return "";
}
J2KImage[] images = client.ImageManager.GetImages(); J2KImage[] images = client.ImageManager.GetImages();