Merge branch 'master' into httptests

httptests
UbitUmarov 2017-05-27 05:47:05 +01:00
commit c54985f8a1
20 changed files with 197 additions and 208 deletions

View File

@ -136,12 +136,15 @@ namespace OpenSim.Framework.Monitoring
if(m_jobQueue.Count <= 0)
m_cancelSource.Cancel();
if(m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop))
m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop);
m_finishedProcessingAfterStop.Close();
}
finally
{
m_cancelSource.Dispose();
if(m_cancelSource != null)
m_cancelSource.Dispose();
if(m_finishedProcessingAfterStop != null)
m_finishedProcessingAfterStop.Dispose();
}
}
}

View File

@ -193,7 +193,7 @@ namespace OpenSim.Framework.Monitoring
m_watchdogTimer.Dispose();
m_watchdogTimer = null;
}
foreach(ThreadWatchdogInfo twi in m_threads.Values)
{
Thread t = twi.Thread;
@ -341,6 +341,8 @@ namespace OpenSim.Framework.Monitoring
/// <param name="e"></param>
private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if(!m_enabled)
return;
int now = Environment.TickCount & Int32.MaxValue;
int msElapsed = now - LastWatchdogThreadTick;
@ -358,21 +360,26 @@ namespace OpenSim.Framework.Monitoring
List<ThreadWatchdogInfo> callbackInfos = null;
List<ThreadWatchdogInfo> threadsToRemove = null;
const ThreadState thgone = ThreadState.Stopped | ThreadState.Aborted | ThreadState.AbortRequested;
lock (m_threads)
{
foreach(ThreadWatchdogInfo threadInfo in m_threads.Values)
{
if(threadInfo.Thread.ThreadState == ThreadState.Stopped)
if(!m_enabled)
return;
if(!threadInfo.Thread.IsAlive || (threadInfo.Thread.ThreadState & thgone) != 0)
{
if(threadsToRemove == null)
threadsToRemove = new List<ThreadWatchdogInfo>();
threadsToRemove.Add(threadInfo);
/*
if(callbackInfos == null)
callbackInfos = new List<ThreadWatchdogInfo>();
callbackInfos.Add(threadInfo);
*/
}
else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout)
{

View File

@ -420,6 +420,7 @@ namespace OpenSim.Framework
set { m_remotingPort = value; }
}
/// <value>
/// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
///
@ -427,42 +428,7 @@ namespace OpenSim.Framework
/// </value>
public IPEndPoint ExternalEndPoint
{
get
{
// Old one defaults to IPv6
//return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
IPAddress ia = null;
// If it is already an IP, don't resolve it - just return directly
if (IPAddress.TryParse(m_externalHostName, out ia))
return new IPEndPoint(ia, m_internalEndPoint.Port);
// Reset for next check
ia = null;
try
{
foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
{
if (ia == null)
ia = Adr;
if (Adr.AddressFamily == AddressFamily.InterNetwork)
{
ia = Adr;
break;
}
}
}
catch (SocketException e)
{
throw new Exception(
"Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
e + "' attached to this exception", e);
}
return new IPEndPoint(ia, m_internalEndPoint.Port);
}
get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); }
set { m_externalHostName = value.ToString(); }
}

View File

@ -429,6 +429,65 @@ namespace OpenSim.Framework
return regionCoord << 8;
}
public static IPEndPoint getEndPoint(IPAddress ia, int port)
{
if(ia == null)
return null;
IPEndPoint newEP = null;
try
{
newEP = new IPEndPoint(ia, port);
}
catch
{
newEP = null;
}
return newEP;
}
public static IPEndPoint getEndPoint(string hostname, int port)
{
IPAddress ia = null;
// If it is already an IP, don't resolve it - just return directly
// we should not need this
if (IPAddress.TryParse(hostname, out ia))
{
if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any))
return null;
return getEndPoint(ia, port);
}
// Reset for next check
ia = null;
try
{
foreach (IPAddress Adr in Dns.GetHostAddresses(hostname))
{
if (ia == null)
ia = Adr;
if (Adr.AddressFamily == AddressFamily.InterNetwork)
{
ia = Adr;
break;
}
}
}
catch // (SocketException e)
{
/*throw new Exception(
"Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
e + "' attached to this exception", e);*/
// Don't throw a fatal exception here, instead, return Null and handle it in the caller.
// Reason is, on systems such as OSgrid it has occured that known hostnames stop
// resolving and thus make surrounding regions crash out with this exception.
return null;
}
return getEndPoint(ia,port);
}
public static bool checkServiceURI(string uristr, out string serviceURI)
{
serviceURI = string.Empty;

View File

@ -511,8 +511,6 @@ namespace OpenSim
private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi)
{
int now = Environment.TickCount & Int32.MaxValue;
if(twi.Thread.ThreadState == System.Threading.ThreadState.Stopped)
return;
m_log.ErrorFormat(
"[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}",
twi.Thread.Name,

View File

@ -203,10 +203,10 @@ namespace OpenSim.Region.ClientStack.Linden
{
while(true)
{
aPollRequest poolreq = m_queue.Dequeue(1000);
aPollRequest poolreq = m_queue.Dequeue(4500);
Watchdog.UpdateThread();
if(m_NumberScenes <= 0)
return;
Watchdog.UpdateThread();
if(poolreq.reqID != UUID.Zero)
poolreq.thepoll.Process(poolreq);
}

View File

@ -445,10 +445,10 @@ namespace OpenSim.Region.ClientStack.Linden
{
while (true)
{
aPollRequest poolreq = m_queue.Dequeue(2000);
aPollRequest poolreq = m_queue.Dequeue(4500);
Watchdog.UpdateThread();
if(m_NumberScenes <= 0)
return;
Watchdog.UpdateThread();
if(poolreq.reqID != UUID.Zero)
poolreq.thepoll.Process(poolreq);
}

View File

@ -479,10 +479,9 @@ namespace OpenSim.Region.ClientStack.Linden
{
while (true)
{
aPollRequest poolreq = m_queue.Dequeue(4500);
Watchdog.UpdateThread();
aPollRequest poolreq = m_queue.Dequeue(5000);
if (poolreq != null && poolreq.thepoll != null)
{
try

View File

@ -646,7 +646,7 @@ namespace OpenSim.Region.CoreModules.Asset
if (m_LogLevel >= 2)
m_log.Debug("[FLOTSAM ASSET CACHE]: Clearing caches.");
if (m_FileCacheEnabled)
if (m_FileCacheEnabled && Directory.Exists(m_CacheDirectory))
{
foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
{
@ -681,10 +681,10 @@ namespace OpenSim.Region.CoreModules.Asset
// before cleaning up expired files we must scan the objects in the scene to make sure that we retain
// such local assets if they have not been recently accessed.
TouchAllSceneAssets(false);
foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
if(Directory.Exists(m_CacheDirectory))
{
CleanExpiredFiles(dir, purgeLine);
foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
CleanExpiredFiles(dir, purgeLine);
}
lock(timerLock)
@ -706,6 +706,9 @@ namespace OpenSim.Region.CoreModules.Asset
{
try
{
if(!Directory.Exists(dir))
return;
foreach (string file in Directory.GetFiles(dir))
{
if (File.GetLastAccessTime(file) < purgeLine)
@ -869,6 +872,9 @@ namespace OpenSim.Region.CoreModules.Asset
/// <returns></returns>
private int GetFileCacheCount(string dir)
{
if(!Directory.Exists(dir))
return 0;
int count = Directory.GetFiles(dir).Length;
foreach (string subdir in Directory.GetDirectories(dir))
@ -987,6 +993,9 @@ namespace OpenSim.Region.CoreModules.Asset
/// </summary>
private void ClearFileCache()
{
if(!Directory.Exists(m_CacheDirectory))
return;
foreach (string dir in Directory.GetDirectories(m_CacheDirectory))
{
try

View File

@ -658,7 +658,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
public void Process()
{
_finished = false;
httpThread = WorkManager.StartThread(SendRequest, "HttpRequestThread", ThreadPriority.BelowNormal, true, false);
httpThread = WorkManager.StartThread(SendRequest, "HttpRequestThread", ThreadPriority.BelowNormal, true, false, null, int.MaxValue);
}
/*

View File

@ -385,7 +385,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
storage[handle] = region;
byname[region.RegionName] = handle;
byuuid[region.RegionID] = handle;
}
public void Remove(GridRegion region)
@ -400,7 +399,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
ulong handle = region.RegionHandle & HANDLEMASK;
if(storage != null)
storage.Remove(handle);
{
if(storage.ContainsKey(handle))
{
storage[handle] = null;
storage.Remove(handle);
}
}
removeFromInner(region);
if(expires != null)
{
@ -424,6 +429,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if(byuuid != null)
byuuid.Remove(r.RegionID);
removeFromInner(r);
storage[handle] = null;
}
storage.Remove(handle);
}
@ -581,27 +587,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
if(expires == null || expires.Count == 0)
return 0;
int expiresCount = expires.Count;
List<ulong> toexpire = new List<ulong>();
foreach(KeyValuePair<ulong, DateTime> kvp in expires)
{
if(kvp.Value < now)
toexpire.Add(kvp.Key);
}
if(toexpire.Count == 0)
return expires.Count;
int toexpireCount = toexpire.Count;
if(toexpireCount == 0)
return expiresCount;
if(toexpire.Count == expires.Count)
if(toexpireCount == expiresCount)
{
Clear();
return 0;
}
foreach(ulong h in toexpire)
if(storage != null)
{
if(storage != null)
ulong h;
for(int i = 0; i < toexpireCount; i++)
{
h = toexpire[i];
if(storage.ContainsKey(h))
{
GridRegion r = storage[h];
@ -610,14 +621,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if(byuuid != null)
byuuid.Remove(r.RegionID);
removeFromInner(r);
storage[h] = null;
storage.Remove(h);
}
storage.Remove(h);
if(expires != null)
expires.Remove(h);
}
if(expires != null)
expires.Remove(h);
}
else
{
Clear();
return 0;
}
if(expires.Count == 0)
expiresCount = expires.Count;
if(expiresCount == 0)
{
byname = null;
byuuid = null;
@ -626,7 +645,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return 0;
}
return expires.Count;
return expiresCount;
}
public int Count()
@ -693,7 +712,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public class RegionsExpiringCache
{
const double CACHE_PURGE_HZ = 60; // seconds
const double CACHE_PURGE_TIME = 60000; // milliseconds
const int MAX_LOCK_WAIT = 10000; // milliseconds
/// <summary>For thread safety</summary>
@ -702,7 +721,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
object isPurging = new object();
Dictionary<UUID, RegionInfoForScope> InfobyScope = new Dictionary<UUID, RegionInfoForScope>();
private System.Timers.Timer timer = new System.Timers.Timer(TimeSpan.FromSeconds(CACHE_PURGE_HZ).TotalMilliseconds);
private System.Timers.Timer timer = new System.Timers.Timer(CACHE_PURGE_TIME);
public RegionsExpiringCache()
{
@ -965,7 +984,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
if (expiredscopes.Count > 0)
{
foreach (UUID sid in expiredscopes)
{
InfobyScope[sid] = null;
InfobyScope.Remove(sid);
}
}
}
finally { Monitor.Exit(syncRoot); }

View File

@ -716,12 +716,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{
while (true)
{
Watchdog.UpdateThread();
av = null;
st = null;
st = requests.Dequeue(4900); // timeout to make watchdog happy
st = requests.Dequeue(4500);
Watchdog.UpdateThread();
if (st == null || st.agentID == UUID.Zero)
continue;
@ -1152,10 +1151,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
{
while(!m_mapBlockRequestEvent.WaitOne(4900))
{
Watchdog.UpdateThread();
if(m_scene == null)
return;
}
Watchdog.UpdateThread();
lock (m_mapBlockRequestEvent)
{
int total = 0;

View File

@ -226,9 +226,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
try
{
Thread.Sleep(cmdHandlerThreadCycleSleepms);
Watchdog.UpdateThread();
DoOneCmdHandlerPass();
Watchdog.UpdateThread();
}
catch ( System.Threading.ThreadAbortException) { }

View File

@ -79,12 +79,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
private List<string> m_warnings = new List<string>();
// private object m_syncy = new object();
// private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
// private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
// private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
private static UInt64 scriptCompileCounter = 0; // And a counter
public IScriptEngine m_scriptEngine;
@ -251,23 +245,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
}
}
////private ICodeCompiler icc = codeProvider.CreateCompiler();
//public string CompileFromFile(string LSOFileName)
//{
// switch (Path.GetExtension(LSOFileName).ToLower())
// {
// case ".txt":
// case ".lsl":
// Common.ScriptEngineBase.Shared.SendToDebug("Source code is LSL, converting to CS");
// return CompileFromLSLText(File.ReadAllText(LSOFileName));
// case ".cs":
// Common.ScriptEngineBase.Shared.SendToDebug("Source code is CS");
// return CompileFromCSText(File.ReadAllText(LSOFileName));
// default:
// throw new Exception("Unknown script type.");
// }
//}
public string GetCompilerOutput(string assetID)
{
return Path.Combine(ScriptEnginesPath, Path.Combine(
@ -578,8 +555,6 @@ namespace SecondLife
switch (lang)
{
case enumCompileType.vb:
// results = VBcodeProvider.CompileAssemblyFromSource(
// parameters, Script);
provider = CodeDomProvider.CreateProvider("VisualBasic");
break;
case enumCompileType.cs:
@ -594,56 +569,36 @@ namespace SecondLife
if(provider == null)
throw new Exception("Compiler failed to load ");
bool complete = false;
bool retried = false;
bool complete = false;
bool retried = false;
do
do
{
results = provider.CompileAssemblyFromSource(
parameters, Script);
// Deal with an occasional segv in the compiler.
// Rarely, if ever, occurs twice in succession.
// Line # == 0 and no file name are indications that
// this is a native stack trace rather than a normal
// error log.
if (results.Errors.Count > 0)
{
if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) &&
results.Errors[0].Line == 0)
{
// lock (CScodeProvider)
// {
// results = CScodeProvider.CompileAssemblyFromSource(
// parameters, Script);
// }
results = provider.CompileAssemblyFromSource(
parameters, Script);
// Deal with an occasional segv in the compiler.
// Rarely, if ever, occurs twice in succession.
// Line # == 0 and no file name are indications that
// this is a native stack trace rather than a normal
// error log.
if (results.Errors.Count > 0)
{
if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) &&
results.Errors[0].Line == 0)
{
// System.Console.WriteLine("retrying failed compilation");
retried = true;
}
else
{
complete = true;
}
}
else
{
complete = true;
}
} while (!complete);
// break;
// default:
// throw new Exception("Compiler is not able to recongnize " +
// "language type \"" + lang.ToString() + "\"");
// }
// foreach (Type type in results.CompiledAssembly.GetTypes())
// {
// foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
// {
// m_log.DebugFormat("[COMPILER]: {0}.{1}", type.FullName, method.Name);
// }
// }
// System.Console.WriteLine("retrying failed compilation");
retried = true;
}
else
{
complete = true;
}
}
else
{
complete = true;
}
} while (!complete);
//
// WARNINGS AND ERRORS

View File

@ -2149,10 +2149,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
string fn = Path.GetFileName(assemName);
string assem = String.Empty;
string assemNameText = assemName + ".text";
if (File.Exists(assemName + ".text"))
if (File.Exists(assemNameText))
{
FileInfo tfi = new FileInfo(assemName + ".text");
FileInfo tfi = new FileInfo(assemNameText);
if (tfi != null)
{
@ -2160,7 +2161,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
try
{
using (FileStream tfs = File.Open(assemName + ".text",
using (FileStream tfs = File.Open(assemNameText,
FileMode.Open, FileAccess.Read))
{
tfs.Read(tdata, 0, tdata.Length);

View File

@ -478,17 +478,22 @@ namespace OpenSim.Server.Base
XmlDocument doc = new XmlDocument();
doc.LoadXml(data);
try
{
doc.LoadXml(data);
XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
if (rootL.Count != 1)
return ret;
if (rootL.Count != 1)
return ret;
XmlNode rootNode = rootL[0];
ret = ParseElement(rootNode);
XmlNode rootNode = rootL[0];
ret = ParseElement(rootNode);
}
catch (Exception e)
{
m_log.DebugFormat("[serverUtils.ParseXmlResponse]: failed error: {0} \n --- string: {1} - ",e.Message, data);
}
return ret;
}

View File

@ -34,7 +34,7 @@ using System.Reflection;
using System.Timers;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
@ -135,7 +135,11 @@ namespace OpenSim.Services.Connectors
for (int i = 0 ; i < 2 ; i++)
{
Util.FireAndForget(delegate { AssetRequestProcessor();});
m_fetchThreads[i] = WorkManager.StartThread(AssetRequestProcessor,
String.Format("GetTextureWorker{0}", i),
ThreadPriority.Normal,
true,
false);
}
}
@ -357,7 +361,8 @@ namespace OpenSim.Services.Connectors
while (true)
{
r = m_requestQueue.Dequeue(2000);
r = m_requestQueue.Dequeue(4500);
Watchdog.UpdateThread();
if(r== null)
continue;
string uri = r.uri;

View File

@ -462,50 +462,7 @@ namespace OpenSim.Services.Interfaces
/// </value>
public IPEndPoint ExternalEndPoint
{
get
{
IPAddress ia = null;
// If it is already an IP, don't resolve it - just return directly
// we should not need this
if (IPAddress.TryParse(m_externalHostName, out ia))
{
if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any))
return null;
return new IPEndPoint(ia, m_internalEndPoint.Port);
}
// Reset for next check
ia = null;
try
{
foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
{
if (ia == null)
ia = Adr;
if (Adr.AddressFamily == AddressFamily.InterNetwork)
{
ia = Adr;
break;
}
}
}
catch // (SocketException e)
{
/*throw new Exception(
"Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
e + "' attached to this exception", e);*/
// Don't throw a fatal exception here, instead, return Null and handle it in the caller.
// Reason is, on systems such as OSgrid it has occured that known hostnames stop
// resolving and thus make surrounding regions crash out with this exception.
return null;
}
if(ia == null)
return null;
return new IPEndPoint(ia, m_internalEndPoint.Port);
}
get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); }
}
public string ExternalHostName

View File

@ -256,6 +256,10 @@
;; alternative OpenDynamicsEngine engine. ubODEMeshmerizer meshing above MUST be selected also
; physics = ubODE
; ubODE and OpenDynamicsEngine does allocate a lot of memory on stack. On linux you may need to increase its limit
; script opensim-ode-sh starts opensim setting that limit. You may need to increase it even more on large regions
; edit the line ulimit -s 262144, and change this last value
;# {DefaultScriptEngine} {} {Default script engine} {XEngine} XEngine
;; Default script engine to use. Currently, we only have XEngine
; DefaultScriptEngine = "XEngine"

View File

@ -1,4 +1,4 @@
#!/bin/sh
echo "Starting OpenSimulator with ODE. If you get an error saying limit: Operation not permitted. Then you will need to chmod 0600 /etc/limits"
echo "Starting OpenSimulator with ODE or ubOde. If you get an error saying limit: Operation not permitted. Then you will need to chmod 0600 /etc/limits"
ulimit -s 262144
mono OpenSim.exe -physics=OpenDynamicsEngine
mono OpenSim.exe