avoid some large unnecessary strings

httptests
UbitUmarov 2018-01-24 10:02:18 +00:00
parent 5a246026a0
commit fc224b444a
6 changed files with 40 additions and 37 deletions

View File

@ -78,9 +78,6 @@ namespace OpenSim.Capabilities.Handlers
ArrayList foldersrequested = (ArrayList)hash["folders"]; ArrayList foldersrequested = (ArrayList)hash["folders"];
StringBuilder tmpresponse = new StringBuilder(1024);
StringBuilder tmpbadfolders = new StringBuilder(1024);
List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>(); List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>();
for (int i = 0; i < foldersrequested.Count; i++) for (int i = 0; i < foldersrequested.Count; i++)
{ {
@ -101,6 +98,8 @@ namespace OpenSim.Capabilities.Handlers
folders.Add(llsdRequest); folders.Add(llsdRequest);
} }
StringBuilder lastresponse = new StringBuilder(1024);
lastresponse.Append("<llsd>");
if (folders.Count > 0) if (folders.Count > 0)
{ {
List<UUID> bad_folders = new List<UUID>(); List<UUID> bad_folders = new List<UUID>();
@ -115,43 +114,39 @@ namespace OpenSim.Capabilities.Handlers
#pragma warning restore 0612 #pragma warning restore 0612
} }
string inventoryitemstr = string.Empty; if(invcollSet.Count > 0)
foreach (InventoryCollectionWithDescendents icoll in invcollSet)
{ {
LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents); lastresponse.Append("<map><key>folders</key><array>");
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(thiscontents); foreach (InventoryCollectionWithDescendents icoll in invcollSet)
tmpresponse.Append(inventoryitemstr.Substring(6,inventoryitemstr.Length - 13)); {
LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents);
lastresponse.Append(LLSDHelpers.SerialiseLLSDReplyNoHeader(thiscontents));
}
lastresponse.Append("</array></map>");
} }
else
lastresponse.Append("<map><key>folders</key><array /></map>");
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders));
foreach (UUID bad in bad_folders) if(bad_folders.Count > 0)
{ {
tmpbadfolders.Append("<map><key>folder_id</key><uuid>"); lastresponse.Append("<map><key>bad_folders</key><array>");
tmpbadfolders.Append(bad.ToString()); foreach (UUID bad in bad_folders)
tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>"); {
lastresponse.Append("<map><key>folder_id</key><uuid>");
lastresponse.Append(bad.ToString());
lastresponse.Append("</uuid><key>error</key><string>Unknown</string></map>");
}
lastresponse.Append("</array></map>");
} }
} lastresponse.Append("</llsd>");
StringBuilder lastresponse = new StringBuilder(1024);
lastresponse.Append("<llsd>");
if(tmpresponse.Length > 0)
{
lastresponse.Append("<map><key>folders</key><array>");
lastresponse.Append(tmpresponse.ToString());
lastresponse.Append("</array></map>");
} }
else else
lastresponse.Append("<map><key>folders</key><array /></map>");
if(tmpbadfolders.Length > 0)
{ {
lastresponse.Append("<map><key>bad_folders</key><array>"); lastresponse.Append("<map><key>folders</key><array /></map></llsd>");
lastresponse.Append(tmpbadfolders.ToString());
lastresponse.Append("</array></map>");
} }
lastresponse.Append("</llsd>");
return lastresponse.ToString(); return lastresponse.ToString();;
} }
/// <summary> /// <summary>

View File

@ -54,6 +54,19 @@ namespace OpenSim.Framework.Capabilities
return sw.ToString(); return sw.ToString();
} }
public static string SerialiseLLSDReplyNoHeader(object obj)
{
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.None;
SerializeOSDType(writer, obj);
writer.Close();
//m_log.DebugFormat("[LLSD Helpers]: Generated serialized LLSD reply {0}", sw.ToString());
return sw.ToString();
}
private static void SerializeOSDType(XmlTextWriter writer, object obj) private static void SerializeOSDType(XmlTextWriter writer, object obj)
{ {
Type myType = obj.GetType(); Type myType = obj.GetType();

View File

@ -79,7 +79,7 @@ namespace OpenSim.Framework.Monitoring
/// </remarks> /// </remarks>
private bool m_warnOverMaxQueue = true; private bool m_warnOverMaxQueue = true;
private BlockingCollection<Job> m_jobQueue = new BlockingCollection<Job>(new ConcurrentQueue<Job>(), 5000); private BlockingCollection<Job> m_jobQueue = new BlockingCollection<Job>(5000);
private CancellationTokenSource m_cancelSource; private CancellationTokenSource m_cancelSource;

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />

View File

@ -3,9 +3,6 @@
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections> </configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<runtime> <runtime>
<loadFromRemoteSources enabled="true" /> <loadFromRemoteSources enabled="true" />
</runtime> </runtime>

View File

@ -3,9 +3,6 @@
<configSections> <configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections> </configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<runtime> <runtime>
<loadFromRemoteSources enabled="true" /> <loadFromRemoteSources enabled="true" />
</runtime> </runtime>