avoid c# fun things, plus cosmetics

master
UbitUmarov 2020-07-14 17:54:58 +01:00
parent b2068fd39f
commit f32c0ead05
9 changed files with 112 additions and 50 deletions

View File

@ -137,7 +137,7 @@ namespace OpenSim.Framework.Monitoring
} }
if (m_jobQueue != null) if (m_jobQueue != null)
{ {
m_jobQueue .Dispose(); m_jobQueue.Dispose();
m_jobQueue = null; m_jobQueue = null;
} }
} }

View File

@ -147,7 +147,7 @@ namespace OpenSim.Framework
//this is a vector3 now, but all viewers expect a vector4, so keeping like this for now //this is a vector3 now, but all viewers expect a vector4, so keeping like this for now
public Vector4 sunlight_color = new Vector4(0.7342f, 0.7815f, 0.9f, 0.3f); public Vector4 sunlight_color = new Vector4(0.7342f, 0.7815f, 0.9f, 0.3f);
public string Name = "Default"; public string Name = "DefaultSky";
public float cloud_variance = 0; public float cloud_variance = 0;
public float dome_offset = 0.96f; public float dome_offset = 0.96f;

View File

@ -53,9 +53,7 @@ namespace OpenSim.Framework
/// </summary> /// </summary>
public static class WebUtil public static class WebUtil
{ {
private static readonly ILog m_log = private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
/// <summary> /// <summary>
/// Control the printing of certain debug messages. /// Control the printing of certain debug messages.

View File

@ -232,7 +232,6 @@ namespace OpenSim.Region.ClientStack.Linden
private HashSet<UUID> dropedResponses = new HashSet<UUID>(); private HashSet<UUID> dropedResponses = new HashSet<UUID>();
private Scene m_scene; private Scene m_scene;
private ScenePresence m_presence;
public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene) : public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene) :
base(null, uri, null, null, null, null, pId, int.MaxValue) base(null, uri, null, null, null, null, pId, int.MaxValue)
{ {
@ -245,20 +244,19 @@ namespace OpenSim.Region.ClientStack.Linden
APollResponse response; APollResponse response;
if (responses.TryGetValue(requestID, out response)) if (responses.TryGetValue(requestID, out response))
{ {
if (m_presence == null) ScenePresence sp = m_scene.GetScenePresence(pId);
m_presence = m_scene.GetScenePresence(pId);
if (m_presence == null || m_presence.IsDeleted) if (sp == null || sp.IsDeleted)
return true; return true;
OSHttpResponse resp = response.osresponse; OSHttpResponse resp = response.osresponse;
if(Util.GetTimeStamp() - resp.RequestTS > (resp.RawBufferLen > 2000000 ? 200 : 90)) if(Util.GetTimeStamp() - resp.RequestTS > (resp.RawBufferLen > 2000000 ? 200 : 90))
return m_presence.CapCanSendAsset(2, resp.RawBufferLen); return sp.CapCanSendAsset(2, resp.RawBufferLen);
if (resp.Priority > 1) if (resp.Priority > 1)
return m_presence.CapCanSendAsset(1, resp.RawBufferLen); return sp.CapCanSendAsset(1, resp.RawBufferLen);
return m_presence.CapCanSendAsset(2, resp.RawBufferLen); return sp.CapCanSendAsset(2, resp.RawBufferLen);
} }
return false; return false;
} }

View File

@ -748,9 +748,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; m_nextOnQueueEmpty = start + MIN_CALLBACK_MS;
// Asynchronously run the callback // Asynchronously run the callback
if (m_udpServer.OqrEngine.IsRunning) // avoid stupid memory leak
m_udpServer.OqrEngine.QueueJob(AgentID.ToString(), () => FireQueueEmpty(categories)); //if (m_udpServer.OqrEngine.IsRunning)
else // m_udpServer.OqrEngine.QueueJob(AgentID.ToString(), () => FireQueueEmpty(categories));
//else
Util.FireAndForget(FireQueueEmpty, categories, "LLUDPClient.BeginFireQueueEmpty"); Util.FireAndForget(FireQueueEmpty, categories, "LLUDPClient.BeginFireQueueEmpty");
} }
} }
@ -764,16 +765,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// signature</param> /// signature</param>
public void FireQueueEmpty(object o) public void FireQueueEmpty(object o)
{ {
ThrottleOutPacketTypeFlags categories = (ThrottleOutPacketTypeFlags)o;
QueueEmpty callback = OnQueueEmpty; QueueEmpty callback = OnQueueEmpty;
if (callback != null) if (callback != null)
{ {
// if (m_udpServer.IsRunningOutbound) ThrottleOutPacketTypeFlags categories = (ThrottleOutPacketTypeFlags)o;
// {
try { callback(categories); } try { callback(categories); }
catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + categories + ") threw an exception: " + e.Message, e); } catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + categories + ") threw an exception: " + e.Message, e); }
// }
} }
m_isQueueEmptyRunning = false; m_isQueueEmptyRunning = false;

View File

@ -28,9 +28,8 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Collections.Concurrent;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -40,7 +39,6 @@ using Nini.Config;
using Mono.Addins; using Mono.Addins;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring; using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -53,6 +51,12 @@ namespace OpenSim.Region.CoreModules.Asset
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FlotsamAssetCache")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FlotsamAssetCache")]
public class FlotsamAssetCache : ISharedRegionModule, IAssetCache, IAssetService public class FlotsamAssetCache : ISharedRegionModule, IAssetCache, IAssetService
{ {
private struct WriteAssetInfo
{
public string filename;
public AssetBase asset;
}
private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType);
private bool m_Enabled; private bool m_Enabled;
@ -76,6 +80,8 @@ namespace OpenSim.Region.CoreModules.Asset
private ulong m_weakRefHits; private ulong m_weakRefHits;
private static HashSet<string> m_CurrentlyWriting = new HashSet<string>(); private static HashSet<string> m_CurrentlyWriting = new HashSet<string>();
private static BlockingCollection<WriteAssetInfo> m_assetFileWriteQueue = null;
private static CancellationTokenSource m_cancelSource;
private bool m_FileCacheEnabled = true; private bool m_FileCacheEnabled = true;
@ -116,8 +122,6 @@ namespace OpenSim.Region.CoreModules.Asset
m_InvalidChars = invalidChars.ToArray(); m_InvalidChars = invalidChars.ToArray();
} }
private static JobEngine m_DiskWriterEngine = null;
public Type ReplaceableInterface public Type ReplaceableInterface
{ {
get { return null; } get { return null; }
@ -219,6 +223,19 @@ namespace OpenSim.Region.CoreModules.Asset
public void Close() public void Close()
{ {
if(m_Scenes.Count <= 0)
{
if (m_assetFileWriteQueue != null)
{
m_assetFileWriteQueue.Dispose();
m_assetFileWriteQueue = null;
}
if(m_cancelSource != null)
{
m_cancelSource.Dispose();
m_cancelSource = null;
}
}
} }
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
@ -238,13 +255,16 @@ namespace OpenSim.Region.CoreModules.Asset
m_Scenes.Remove(scene); m_Scenes.Remove(scene);
lock(timerLock) lock(timerLock)
{ {
if(m_timerRunning && m_Scenes.Count <= 0) if(m_Scenes.Count <= 0)
{ {
m_timerRunning = false; if (m_timerRunning)
m_CacheCleanTimer.Stop(); {
m_CacheCleanTimer.Close(); m_timerRunning = false;
if (m_FileCacheEnabled && m_DiskWriterEngine != null && m_DiskWriterEngine.IsRunning) m_CacheCleanTimer.Stop();
m_DiskWriterEngine.Stop(); m_CacheCleanTimer.Close();
}
if (m_FileCacheEnabled && m_assetFileWriteQueue != null)
m_cancelSource.Cancel();
} }
} }
} }
@ -270,15 +290,31 @@ namespace OpenSim.Region.CoreModules.Asset
} }
} }
if(m_DiskWriterEngine == null) if (m_FileCacheEnabled && m_assetFileWriteQueue == null)
{ {
m_DiskWriterEngine = new JobEngine("FlotsamWriter", "FlotsamWriter"); m_assetFileWriteQueue = new BlockingCollection<WriteAssetInfo>();
m_DiskWriterEngine.Start(); m_cancelSource = new CancellationTokenSource();
WorkManager.RunInThreadPool(processWrites, null, "FloatsamCacheWriter", false);
} }
} }
} }
} }
private void processWrites(object o)
{
try
{
while(true)
{
if(m_assetFileWriteQueue.TryTake(out WriteAssetInfo wai,-1, m_cancelSource.Token))
{
WriteFileCache(wai.filename,wai.asset,false);
}
}
}
catch{ }
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// IAssetCache // IAssetCache
// //
@ -302,6 +338,9 @@ namespace OpenSim.Region.CoreModules.Asset
private void UpdateFileCache(string key, AssetBase asset, bool replace = false) private void UpdateFileCache(string key, AssetBase asset, bool replace = false)
{ {
if(m_assetFileWriteQueue == null)
return;
string filename = GetFileName(key); string filename = GetFileName(key);
try try
@ -323,8 +362,11 @@ namespace OpenSim.Region.CoreModules.Asset
m_CurrentlyWriting.Add(filename); m_CurrentlyWriting.Add(filename);
} }
// weakreferences should hold and return the asset while async write happens WriteAssetInfo wai = new WriteAssetInfo();
m_DiskWriterEngine?.QueueJob("", delegate { WriteFileCache(filename, asset, replace); }); wai.filename = filename;
wai.asset = asset;
if (m_assetFileWriteQueue != null)
m_assetFileWriteQueue.Add(wai);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -1664,20 +1664,24 @@ namespace OpenSim.Region.Framework.Scenes
*/ */
if (Frame % (m_update_coarse_locations) == 0 && !m_sendingCoarseLocations) if (Frame % (m_update_coarse_locations) == 0 && !m_sendingCoarseLocations)
{ {
m_sendingCoarseLocations = true; if(GetNumberOfClients() > 0)
WorkManager.RunInThreadPool( {
delegate m_sendingCoarseLocations = true;
{ WorkManager.RunInThreadPool(
List<Vector3> coarseLocations; delegate
List<UUID> avatarUUIDs;
SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
// Send coarse locations to clients
ForEachScenePresence(delegate(ScenePresence presence)
{ {
presence.SendCoarseLocations(coarseLocations, avatarUUIDs); List<Vector3> coarseLocations;
}); List<UUID> avatarUUIDs;
m_sendingCoarseLocations = false; SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60);
}, null, string.Format("SendCoarseLocations ({0})", Name)); // Send coarse locations to clients
ForEachScenePresence(delegate(ScenePresence presence)
{
if(!presence.IsNPC)
presence.SendCoarseLocations(coarseLocations, avatarUUIDs);
});
m_sendingCoarseLocations = false;
}, null, string.Format("SendCoarseLocations ({0})", Name));
}
} }
// Get the simulation frame time that the avatar force input // Get the simulation frame time that the avatar force input

View File

@ -564,6 +564,29 @@ namespace OpenSim.Server.Base
return new Dictionary<string, object>(); return new Dictionary<string, object>();
} }
public static Dictionary<string, object> ParseXmlResponse(Stream src)
{
//m_log.DebugFormat("[XXX]: received xml string: {0}", data);
try
{
XmlReaderSettings xset = new XmlReaderSettings() { IgnoreWhitespace = true, IgnoreComments = true, ConformanceLevel = ConformanceLevel.Fragment, CloseInput = true };
XmlParserContext xpc = new XmlParserContext(null, null, null, XmlSpace.None);
xpc.Encoding = Util.UTF8NoBomEncoding;
using (XmlReader xr = XmlReader.Create(src, xset, xpc))
{
if (!xr.ReadToFollowing("ServerResponse"))
return new Dictionary<string, object>();
return ScanXmlResponse(xr);
}
}
catch (Exception e)
{
m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0}", e.Message);
}
return new Dictionary<string, object>();
}
public static IConfig GetConfig(string configFile, string configName) public static IConfig GetConfig(string configFile, string configName)
{ {
IConfig config; IConfig config;

View File

@ -770,7 +770,7 @@
Cap_DispatchRegionInfo = "" Cap_DispatchRegionInfo = ""
Cap_EstateAccess = "localhost" Cap_EstateAccess = "localhost"
//Cap_EstateChangeInfo = "localhost" broken on viewers //Cap_EstateChangeInfo = "localhost" broken on viewers
Cap_EnvironmentSettings = "localhost" Cap_EnvironmentSettings = "localhost" // this also controls ExtEnviroment cap
Cap_EventQueueGet = "localhost" Cap_EventQueueGet = "localhost"
Cap_FetchInventory = "" Cap_FetchInventory = ""
Cap_ObjectMedia = "localhost" Cap_ObjectMedia = "localhost"