Compare commits

...

6 Commits

46 changed files with 2268 additions and 1194 deletions

View File

@ -34,6 +34,10 @@ namespace OpenSim.Framework
{ {
public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>(); public Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
// here be dragons
public delegate void CircuitAddedCallback(uint circuitCode, AgentCircuitData agentData);
public event CircuitAddedCallback onCircuitAdded;
public AgentCircuitManager() public AgentCircuitManager()
{ {
} }
@ -83,6 +87,8 @@ namespace OpenSim.Framework
else else
{ {
AgentCircuits.Add(circuitCode, agentData); AgentCircuits.Add(circuitCode, agentData);
if (null != onCircuitAdded)
onCircuitAdded(circuitCode, agentData);
} }
} }

View File

@ -34,6 +34,7 @@ namespace OpenSim.Framework
{ {
private readonly Queue<T> m_queue = new Queue<T>(); private readonly Queue<T> m_queue = new Queue<T>();
private readonly object m_queueSync = new object(); private readonly object m_queueSync = new object();
private readonly object m_dequeueSync = new object();
public void Enqueue(T value) public void Enqueue(T value)
{ {
@ -49,10 +50,12 @@ namespace OpenSim.Framework
lock (m_queueSync) lock (m_queueSync)
{ {
if (m_queue.Count < 1) if (m_queue.Count < 1)
{
lock (m_dequeueSync)
{ {
Monitor.Wait(m_queueSync); Monitor.Wait(m_queueSync);
} }
}
return m_queue.Dequeue(); return m_queue.Dequeue();
} }
} }
@ -66,8 +69,11 @@ namespace OpenSim.Framework
} }
public int Count() public int Count()
{
lock (m_queueSync)
{ {
return m_queue.Count; return m_queue.Count;
} }
} }
} }
}

View File

@ -97,6 +97,10 @@ namespace OpenSim.Framework
{ {
client.InPacket(packet); client.InPacket(packet);
} }
else
{
m_log.Debug("[ClientManager]: Failed to find client for " + circuitCode.ToString());
}
} }
public void CloseAllAgents(uint circuitCode) public void CloseAllAgents(uint circuitCode)

View File

@ -250,7 +250,9 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId); #if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId);
#endif
NewAssetRequest req = new NewAssetRequest(assetId, callback); NewAssetRequest req = new NewAssetRequest(assetId, callback);
@ -384,14 +386,17 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
} }
#if DEBUG
m_log.DebugFormat("[ASSET CACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); //m_log.DebugFormat("[ASSET CACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result);
#endif
} }
// See IAssetReceiver // See IAssetReceiver
public void AssetReceived(AssetBase asset, bool IsTexture) public void AssetReceived(AssetBase asset, bool IsTexture)
{ {
m_log.DebugFormat("[ASSET CACHE]: Recieved {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID); #if DEBUG
m_log.DebugFormat("[ASSET CACHE]: Received {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID);
#endif
if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
{ {
@ -405,7 +410,9 @@ namespace OpenSim.Framework.Communications.Cache
TextureImage image = new TextureImage(asset); TextureImage image = new TextureImage(asset);
if (Textures.ContainsKey(image.FullID)) if (Textures.ContainsKey(image.FullID))
{ {
m_log.DebugFormat("[ASSET CACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID); #if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID);
#endif
} }
else else
{ {
@ -422,7 +429,9 @@ namespace OpenSim.Framework.Communications.Cache
AssetInfo assetInf = new AssetInfo(asset); AssetInfo assetInf = new AssetInfo(asset);
if (Assets.ContainsKey(assetInf.FullID)) if (Assets.ContainsKey(assetInf.FullID))
{ {
m_log.DebugFormat("[ASSET CACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID); #if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID);
#endif
} }
else else
{ {
@ -435,7 +444,9 @@ namespace OpenSim.Framework.Communications.Cache
if (RequestedAssets.ContainsKey(assetInf.FullID)) if (RequestedAssets.ContainsKey(assetInf.FullID))
{ {
m_log.DebugFormat("[ASSET CACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID); #if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID);
#endif
AssetRequest req = RequestedAssets[assetInf.FullID]; AssetRequest req = RequestedAssets[assetInf.FullID];
req.AssetInf = assetInf; req.AssetInf = assetInf;

View File

@ -137,7 +137,9 @@ namespace OpenSim.Framework.Communications.Cache
req.IsTexture = isTexture; req.IsTexture = isTexture;
m_assetRequests.Enqueue(req); m_assetRequests.Enqueue(req);
#if DEBUG
m_log.InfoFormat("[ASSET SERVER]: Added {0} to request queue", assetID); m_log.InfoFormat("[ASSET SERVER]: Added {0} to request queue", assetID);
#endif
} }
public virtual void UpdateAsset(AssetBase asset) public virtual void UpdateAsset(AssetBase asset)

View File

@ -52,7 +52,9 @@ namespace OpenSim.Framework.Communications.Cache
Stream s = null; Stream s = null;
try try
{ {
m_log.DebugFormat("[ASSETCACHE]: Querying for {0}", req.AssetID.ToString()); #if DEBUG
//m_log.DebugFormat("[GRID ASSET CLIENT]: Querying for {0}", req.AssetID.ToString());
#endif
RestClient rc = new RestClient(_assetServerUrl); RestClient rc = new RestClient(_assetServerUrl);
rc.AddResourcePath("assets"); rc.AddResourcePath("assets");
@ -72,9 +74,9 @@ namespace OpenSim.Framework.Communications.Cache
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error("[ASSETCACHE]: " + e.Message); m_log.Error("[GRID ASSET CLIENT]: " + e.Message);
m_log.DebugFormat("[ASSETCACHE]: Getting asset {0}", req.AssetID.ToString()); m_log.DebugFormat("[GRID ASSET CLIENT]: Getting asset {0}", req.AssetID.ToString());
m_log.Error("[ASSETCACHE]: " + e.StackTrace); m_log.Error("[GRID ASSET CLIENT]: " + e.StackTrace);
} }
return null; return null;
@ -95,19 +97,19 @@ namespace OpenSim.Framework.Communications.Cache
// XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); // XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
// xs.Serialize(s, asset); // xs.Serialize(s, asset);
// RestClient rc = new RestClient(_assetServerUrl); // RestClient rc = new RestClient(_assetServerUrl);
m_log.Info("[ASSET]: Storing asset"); m_log.Info("[GRID ASSET CLIENT]: Storing asset");
//rc.AddResourcePath("assets"); //rc.AddResourcePath("assets");
// rc.RequestMethod = "POST"; // rc.RequestMethod = "POST";
// rc.Request(s); // rc.Request(s);
//m_log.InfoFormat("[ASSET]: Stored {0}", rc); //m_log.InfoFormat("[ASSET]: Stored {0}", rc);
m_log.Info("[ASSET]: Sending to " + _assetServerUrl + "/assets/"); m_log.Info("[GRID ASSET CLIENT]: Sending to " + _assetServerUrl + "/assets/");
RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset); RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error("[ASSETS]: " + e.Message); m_log.Error("[GRID ASSET CLIENT]: " + e.Message);
} }
} }

View File

@ -475,6 +475,7 @@ namespace OpenSim.Region.Capabilities
public class AssetUploader public class AssetUploader
{ {
public event UpLoadedAsset OnUpLoad; public event UpLoadedAsset OnUpLoad;
private UpLoadedAsset handler001 = null;
private string uploaderPath = String.Empty; private string uploaderPath = String.Empty;
private LLUUID newAssetID; private LLUUID newAssetID;
@ -528,10 +529,10 @@ namespace OpenSim.Region.Capabilities
{ {
SaveAssetToFile(m_assetName + ".jp2", data); SaveAssetToFile(m_assetName + ".jp2", data);
} }
handler001 = OnUpLoad;
if (OnUpLoad != null) if (handler001 != null)
{ {
OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); handler001(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType);
} }
return res; return res;
@ -568,6 +569,8 @@ namespace OpenSim.Region.Capabilities
{ {
public event UpdateItem OnUpLoad; public event UpdateItem OnUpLoad;
private UpdateItem handler001 = null;
private string uploaderPath = String.Empty; private string uploaderPath = String.Empty;
private LLUUID inventoryItemID; private LLUUID inventoryItemID;
private BaseHttpServer httpListener; private BaseHttpServer httpListener;
@ -595,10 +598,10 @@ namespace OpenSim.Region.Capabilities
string res = String.Empty; string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
LLUUID assetID = LLUUID.Zero; LLUUID assetID = LLUUID.Zero;
handler001 = OnUpLoad;
if (OnUpLoad != null) if (handler001 != null)
{ {
assetID = OnUpLoad(inv, data); assetID = handler001(inv, data);
} }
uploadComplete.new_asset = assetID.ToString(); uploadComplete.new_asset = assetID.ToString();
@ -648,6 +651,8 @@ namespace OpenSim.Region.Capabilities
{ {
public event UpdateTaskScript OnUpLoad; public event UpdateTaskScript OnUpLoad;
private UpdateTaskScript handler001 = null;
private string uploaderPath = String.Empty; private string uploaderPath = String.Empty;
private LLUUID inventoryItemID; private LLUUID inventoryItemID;
private LLUUID primID; private LLUUID primID;
@ -688,9 +693,10 @@ namespace OpenSim.Region.Capabilities
string res = String.Empty; string res = String.Empty;
LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete();
if (OnUpLoad != null) handler001 = OnUpLoad;
if (handler001 != null)
{ {
OnUpLoad(inventoryItemID, primID, isScriptRunning, data); handler001(inventoryItemID, primID, isScriptRunning, data);
} }
uploadComplete.item_id = inventoryItemID; uploadComplete.item_id = inventoryItemID;

View File

@ -528,6 +528,11 @@ namespace OpenSim.Framework
event MoneyBalanceRequest OnMoneyBalanceRequest; event MoneyBalanceRequest OnMoneyBalanceRequest;
EndPoint EndPoint
{
set;
get;
}
LLVector3 StartPos { get; set; } LLVector3 StartPos { get; set; }
@ -646,7 +651,7 @@ namespace OpenSim.Framework
byte[] GetThrottlesPacked(float multiplier); byte[] GetThrottlesPacked(float multiplier);
bool Claim(EndPoint ep, UseCircuitCodePacket usePacket);
void SetDebug(int newDebug); void SetDebug(int newDebug);
void InPacket(Packet NewPack); void InPacket(Packet NewPack);
void Close(bool ShutdownCircuit); void Close(bool ShutdownCircuit);

View File

@ -46,7 +46,17 @@ namespace OpenSim.Framework
public event RegionUp OnRegionUp; public event RegionUp OnRegionUp;
public event ChildAgentUpdate OnChildAgentUpdate; public event ChildAgentUpdate OnChildAgentUpdate;
private ExpectUserDelegate handler001 = null; // OnExpectUser
private ExpectPrimDelegate handler002 = null; // OnExpectPrim;
private GenericCall2 handler003 = null; // OnExpectChildAgent;
private AgentCrossing handler004 = null; // OnAvatarCrossingIntoRegion;
private PrimCrossing handler005 = null; // OnPrimCrossingIntoRegion;
private UpdateNeighbours handler006 = null; // OnNeighboursUpdate;
private AcknowledgeAgentCross handler007 = null; // OnAcknowledgeAgentCrossed;
private AcknowledgePrimCross handler008 = null; // OnAcknowledgePrimCrossed;
private CloseAgentConnection handler009 = null; // OnCloseAgentConnection;
private RegionUp handler010 = null; // OnRegionUp;
private ChildAgentUpdate handler011 = null; // OnChildAgentUpdate;
public string debugRegionName = String.Empty; public string debugRegionName = String.Empty;
@ -58,9 +68,10 @@ namespace OpenSim.Framework
/// <returns></returns> /// <returns></returns>
public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent)
{ {
if (OnExpectUser != null) handler001 = OnExpectUser;
if (handler001 != null)
{ {
OnExpectUser(regionHandle, agent); handler001(regionHandle, agent);
return true; return true;
} }
@ -70,9 +81,10 @@ namespace OpenSim.Framework
public virtual bool TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData) public virtual bool TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData)
{ {
if (OnExpectPrim != null) handler002 = OnExpectPrim;
if (handler002 != null)
{ {
OnExpectPrim(regionHandle, primID, objData); handler002(regionHandle, primID, objData);
return true; return true;
} }
return false; return false;
@ -80,9 +92,10 @@ namespace OpenSim.Framework
public virtual bool TriggerRegionUp(RegionInfo region) public virtual bool TriggerRegionUp(RegionInfo region)
{ {
if (OnRegionUp != null) handler010 = OnRegionUp;
if (handler010 != null)
{ {
OnRegionUp(region); handler010(region);
return true; return true;
} }
return false; return false;
@ -90,9 +103,10 @@ namespace OpenSim.Framework
public virtual bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) public virtual bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
{ {
if (OnChildAgentUpdate != null) handler011 = OnChildAgentUpdate;
if (handler011 != null)
{ {
OnChildAgentUpdate(regionHandle, cAgentData); handler011(regionHandle, cAgentData);
return true; return true;
} }
return false; return false;
@ -101,9 +115,10 @@ namespace OpenSim.Framework
public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position,
bool isFlying) bool isFlying)
{ {
if (OnAvatarCrossingIntoRegion != null) handler004 = OnAvatarCrossingIntoRegion;
if (handler004 != null)
{ {
OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); handler004(regionHandle, agentID, position, isFlying);
return true; return true;
} }
return false; return false;
@ -112,9 +127,10 @@ namespace OpenSim.Framework
public virtual bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, public virtual bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position,
bool isPhysical) bool isPhysical)
{ {
if (OnPrimCrossingIntoRegion != null) handler005 = OnPrimCrossingIntoRegion;
if (handler005 != null)
{ {
OnPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical); handler005(regionHandle, primID, position, isPhysical);
return true; return true;
} }
return false; return false;
@ -122,9 +138,10 @@ namespace OpenSim.Framework
public virtual bool TriggerAcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) public virtual bool TriggerAcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID)
{ {
if (OnAcknowledgeAgentCrossed != null) handler007 = OnAcknowledgeAgentCrossed;
if (handler007 != null)
{ {
OnAcknowledgeAgentCrossed(regionHandle, agentID); handler007(regionHandle, agentID);
return true; return true;
} }
return false; return false;
@ -132,9 +149,10 @@ namespace OpenSim.Framework
public virtual bool TriggerAcknowledgePrimCrossed(ulong regionHandle, LLUUID primID) public virtual bool TriggerAcknowledgePrimCrossed(ulong regionHandle, LLUUID primID)
{ {
if (OnAcknowledgePrimCrossed != null) handler008 = OnAcknowledgePrimCrossed;
if (handler008 != null)
{ {
OnAcknowledgePrimCrossed(regionHandle, primID); handler008(regionHandle, primID);
return true; return true;
} }
return false; return false;
@ -142,9 +160,10 @@ namespace OpenSim.Framework
public virtual bool TriggerCloseAgentConnection(ulong regionHandle, LLUUID agentID) public virtual bool TriggerCloseAgentConnection(ulong regionHandle, LLUUID agentID)
{ {
if (OnCloseAgentConnection != null) handler009 = OnCloseAgentConnection;
if (handler009 != null)
{ {
OnCloseAgentConnection(regionHandle, agentID); handler009(regionHandle, agentID);
return true; return true;
} }
@ -158,9 +177,10 @@ namespace OpenSim.Framework
/// <returns></returns> /// <returns></returns>
public virtual bool TriggerExpectChildAgent() public virtual bool TriggerExpectChildAgent()
{ {
if (OnExpectChildAgent != null) handler003 = OnExpectChildAgent;
if (handler003 != null)
{ {
OnExpectChildAgent(); handler003();
return true; return true;
} }
@ -175,9 +195,10 @@ namespace OpenSim.Framework
/// <returns></returns> /// <returns></returns>
public virtual bool TriggerOnNeighboursUpdate(List<RegionInfo> neighbours) public virtual bool TriggerOnNeighboursUpdate(List<RegionInfo> neighbours)
{ {
if (OnNeighboursUpdate != null) handler006 = OnNeighboursUpdate;
if (handler006 != null)
{ {
OnNeighboursUpdate(neighbours); handler006(neighbours);
return true; return true;
} }
@ -186,8 +207,9 @@ namespace OpenSim.Framework
public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID)
{ {
if (OnCloseAgentConnection != null) handler009 = OnCloseAgentConnection;
return OnCloseAgentConnection(regionHandle, agentID); if (handler009 != null)
return handler009(regionHandle, agentID);
return false; return false;
} }

View File

@ -26,7 +26,14 @@
* *
*/ */
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Statistics.Interfaces;
using libsecondlife;
namespace OpenSim.Framework.Statistics namespace OpenSim.Framework.Statistics
{ {
@ -42,6 +49,12 @@ namespace OpenSim.Framework.Statistics
public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } }
public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } } public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } }
/// <summary>
/// Retain a dictionary of all packet queues stats reporters
/// </summary>
private IDictionary<LLUUID, PacketQueueStatsReporter> packetQueueStatsReporters
= new Dictionary<LLUUID, PacketQueueStatsReporter>();
public void AddAsset(AssetBase asset) public void AddAsset(AssetBase asset)
{ {
assetsInCache++; assetsInCache++;
@ -58,17 +71,87 @@ namespace OpenSim.Framework.Statistics
} }
} }
/// <summary>
/// Register as a packet queue stats provider
/// </summary>
/// <param name="uuid">An agent LLUUID</param>
/// <param name="provider"></param>
public void RegisterPacketQueueStatsProvider(LLUUID uuid, IPullStatsProvider provider)
{
lock (packetQueueStatsReporters)
{
packetQueueStatsReporters[uuid] = new PacketQueueStatsReporter(provider);
}
}
/// <summary>
/// Deregister a packet queue stats provider
/// </summary>
/// <param name="uuid">An agent LLUUID</param>
public void DeregisterPacketQueueStatsProvider(LLUUID uuid)
{
lock (packetQueueStatsReporters)
{
packetQueueStatsReporters.Remove(uuid);
}
}
/// <summary> /// <summary>
/// Report back collected statistical information. /// Report back collected statistical information.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string Report() public string Report()
{ {
return string.Format( StringBuilder sb = new StringBuilder(Environment.NewLine);
sb.Append("ASSET CACHE STATISTICS");
sb.Append(Environment.NewLine);
sb.Append(
string.Format(
@"Asset cache contains {0,6} assets using {1,10:0.000}K @"Asset cache contains {0,6} assets using {1,10:0.000}K
Texture cache contains {2,6} textures using {3,10:0.000}K", Texture cache contains {2,6} textures using {3,10:0.000}K" + Environment.NewLine,
AssetsInCache, AssetCacheMemoryUsage / 1024.0, AssetsInCache, AssetCacheMemoryUsage / 1024.0,
TexturesInCache, TextureCacheMemoryUsage / 1024.0); TexturesInCache, TextureCacheMemoryUsage / 1024.0));
sb.Append(Environment.NewLine);
sb.Append("PACKET QUEUE STATISTICS");
sb.Append(Environment.NewLine);
sb.Append("Agent UUID ");
sb.Append(
string.Format(
" {0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
"Send", "In", "Out", "Resend", "Land", "Wind", "Cloud", "Task", "Texture", "Asset"));
sb.Append(Environment.NewLine);
foreach (LLUUID key in packetQueueStatsReporters.Keys)
{
sb.Append(string.Format("{0}: ", key));
sb.Append(packetQueueStatsReporters[key].Report());
sb.Append(Environment.NewLine);
}
return sb.ToString();
}
}
/// <summary>
/// Pull packet queue stats from packet queues and report
/// </summary>
public class PacketQueueStatsReporter
{
private IPullStatsProvider m_statsProvider;
public PacketQueueStatsReporter(IPullStatsProvider provider)
{
m_statsProvider = provider;
}
/// <summary>
/// Report back collected statistical information.
/// </summary>
/// <returns></returns>
public string Report()
{
return m_statsProvider.GetStats();
} }
} }
} }

View File

@ -52,6 +52,8 @@ namespace OpenSim.Grid.UserServer
public event UserLoggedInAtLocation OnUserLoggedInAtLocation; public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
private UserLoggedInAtLocation handler001 = null;
public UserConfig m_config; public UserConfig m_config;
public UserLoginService( public UserLoginService(
@ -214,9 +216,10 @@ namespace OpenSim.Grid.UserServer
// Send // Send
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
if (OnUserLoggedInAtLocation != null) handler001 = OnUserLoggedInAtLocation;
if (handler001 != null)
{ {
OnUserLoggedInAtLocation(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos); handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,26 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Timers; using System.Timers;
using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.Statistics.Interfaces;
using Timer=System.Timers.Timer; using Timer=System.Timers.Timer;
namespace OpenSim.Region.ClientStack namespace OpenSim.Region.ClientStack
{ {
public class PacketQueue public class PacketQueue : IPullStatsProvider
{ {
//private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private bool m_enabled = true; private bool m_enabled = false;
public bool Enable
{
get { return m_enabled; }
set { m_enabled = value; m_log.Debug("[PacketQueue]: Enabled == " + value.ToString()); }
}
private BlockingQueue<QueItem> SendQueue; private BlockingQueue<QueItem> SendQueue;
@ -77,7 +86,12 @@ namespace OpenSim.Region.ClientStack
// private long ThrottleInterval; // private long ThrottleInterval;
private Timer throttleTimer; private Timer throttleTimer;
public PacketQueue() /// <summary>
/// backreference so we can push packets out the client. May be temporary.
/// </summary>
private ClientView Client;
public PacketQueue(ClientView client)
{ {
// While working on this, the BlockingQueue had me fooled for a bit. // While working on this, the BlockingQueue had me fooled for a bit.
// The Blocking queue causes the thread to stop until there's something // The Blocking queue causes the thread to stop until there's something
@ -86,6 +100,8 @@ namespace OpenSim.Region.ClientStack
SendQueue = new BlockingQueue<QueItem>(); SendQueue = new BlockingQueue<QueItem>();
Client = client;
IncomingPacketQueue = new Queue<QueItem>(); IncomingPacketQueue = new Queue<QueItem>();
OutgoingPacketQueue = new Queue<QueItem>(); OutgoingPacketQueue = new Queue<QueItem>();
ResendOutgoingPacketQueue = new Queue<QueItem>(); ResendOutgoingPacketQueue = new Queue<QueItem>();
@ -116,6 +132,11 @@ namespace OpenSim.Region.ClientStack
// TIMERS needed for this // TIMERS needed for this
// LastThrottle = DateTime.Now.Ticks; // LastThrottle = DateTime.Now.Ticks;
// ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);
if (StatsManager.SimExtraStats != null)
{
StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(client.AgentId, this);
}
} }
/* STANDARD QUEUE MANIPULATION INTERFACES */ /* STANDARD QUEUE MANIPULATION INTERFACES */
@ -123,13 +144,6 @@ namespace OpenSim.Region.ClientStack
public void Enqueue(QueItem item) public void Enqueue(QueItem item)
{ {
if (!m_enabled)
{
return;
}
// We could micro lock, but that will tend to actually
// probably be worse than just synchronizing on SendQueue
lock (this) lock (this)
{ {
switch (item.throttleType) switch (item.throttleType)
@ -159,7 +173,7 @@ namespace OpenSim.Region.ClientStack
default: default:
// Acknowledgements and other such stuff should go directly to the blocking Queue // Acknowledgements and other such stuff should go directly to the blocking Queue
// Throttling them may and likely 'will' be problematic // Throttling them may and likely 'will' be problematic
SendQueue.Enqueue(item); Client.ProcessOutPacket(item.Packet);
break; break;
} }
} }
@ -174,39 +188,34 @@ namespace OpenSim.Region.ClientStack
{ {
lock (this) lock (this)
{ {
while (PacketsWaiting()) while (ResendOutgoingPacketQueue.Count > 0)
{ {
//Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. Client.ProcessOutPacket(ResendOutgoingPacketQueue.Dequeue().Packet);
if (ResendOutgoingPacketQueue.Count > 0) }
while (LandOutgoingPacketQueue.Count > 0)
{ {
SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue()); Client.ProcessOutPacket(LandOutgoingPacketQueue.Dequeue().Packet);
} }
if (LandOutgoingPacketQueue.Count > 0) while (WindOutgoingPacketQueue.Count > 0)
{ {
SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); Client.ProcessOutPacket(WindOutgoingPacketQueue.Dequeue().Packet);
} }
if (WindOutgoingPacketQueue.Count > 0) while (CloudOutgoingPacketQueue.Count > 0)
{ {
SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); Client.ProcessOutPacket(CloudOutgoingPacketQueue.Dequeue().Packet);
} }
if (CloudOutgoingPacketQueue.Count > 0) while (TaskOutgoingPacketQueue.Count > 0)
{ {
SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); Client.ProcessOutPacket(TaskOutgoingPacketQueue.Dequeue().Packet);
} }
if (TaskOutgoingPacketQueue.Count > 0) while (TextureOutgoingPacketQueue.Count > 0)
{ {
SendQueue.Enqueue(TaskOutgoingPacketQueue.Dequeue()); Client.ProcessOutPacket(TextureOutgoingPacketQueue.Dequeue().Packet);
} }
if (TextureOutgoingPacketQueue.Count > 0) while (AssetOutgoingPacketQueue.Count > 0)
{ {
SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); Client.ProcessOutPacket(AssetOutgoingPacketQueue.Dequeue().Packet);
} }
if (AssetOutgoingPacketQueue.Count > 0)
{
SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue());
}
}
// m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets");
} }
} }
@ -214,6 +223,11 @@ namespace OpenSim.Region.ClientStack
{ {
m_enabled = false; m_enabled = false;
throttleTimer.Stop(); throttleTimer.Stop();
if (StatsManager.SimExtraStats != null)
{
StatsManager.SimExtraStats.DeregisterPacketQueueStatsProvider(Client.AgentId);
}
} }
private void ResetCounters() private void ResetCounters()
@ -264,56 +278,49 @@ namespace OpenSim.Region.ClientStack
if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); QueItem qpack = ResendOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
ResendThrottle.Add(qpack.Packet.ToBytes().Length); ResendThrottle.Add(qpack.Packet.ToBytes().Length);
} }
if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = LandOutgoingPacketQueue.Dequeue(); QueItem qpack = LandOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
LandThrottle.Add(qpack.Packet.ToBytes().Length); LandThrottle.Add(qpack.Packet.ToBytes().Length);
} }
if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = WindOutgoingPacketQueue.Dequeue(); QueItem qpack = WindOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
WindThrottle.Add(qpack.Packet.ToBytes().Length); WindThrottle.Add(qpack.Packet.ToBytes().Length);
} }
if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); QueItem qpack = CloudOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
CloudThrottle.Add(qpack.Packet.ToBytes().Length); CloudThrottle.Add(qpack.Packet.ToBytes().Length);
} }
if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0) if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); QueItem qpack = TaskOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
TaskThrottle.Add(qpack.Packet.ToBytes().Length); TaskThrottle.Add(qpack.Packet.ToBytes().Length);
} }
if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); QueItem qpack = TextureOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
TextureThrottle.Add(qpack.Packet.ToBytes().Length); TextureThrottle.Add(qpack.Packet.ToBytes().Length);
} }
if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0)
{ {
QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); QueItem qpack = AssetOutgoingPacketQueue.Dequeue();
Client.ProcessOutPacket(qpack.Packet);
SendQueue.Enqueue(qpack);
TotalThrottle.Add(qpack.Packet.ToBytes().Length); TotalThrottle.Add(qpack.Packet.ToBytes().Length);
AssetThrottle.Add(qpack.Packet.ToBytes().Length); AssetThrottle.Add(qpack.Packet.ToBytes().Length);
} }
@ -337,17 +344,18 @@ namespace OpenSim.Region.ClientStack
// wait for the timer to fire to put things into the // wait for the timer to fire to put things into the
// output queue // output queue
if ((q.Count == 0) && (throttle.UnderLimit())) if (m_enabled && (q.Count == 0) && (throttle.UnderLimit()))
{ {
Monitor.Enter(this); Monitor.Enter(this);
throttle.Add(item.Packet.ToBytes().Length); throttle.Add(item.Packet.ToBytes().Length);
TotalThrottle.Add(item.Packet.ToBytes().Length); TotalThrottle.Add(item.Packet.ToBytes().Length);
SendQueue.Enqueue(item); Client.ProcessOutPacket(item.Packet);
Monitor.Pulse(this); Monitor.Pulse(this);
Monitor.Exit(this); Monitor.Exit(this);
} }
else else
{ {
// m_log.Debug("[PacketQueue]: ThrottleCheck Queueing " + item.Incoming.ToString() + " packet " + item.Packet.Type.ToString());
q.Enqueue(item); q.Enqueue(item);
} }
} }
@ -483,5 +491,21 @@ namespace OpenSim.Region.ClientStack
// effectively wiggling the slider causes things reset // effectively wiggling the slider causes things reset
ResetCounters(); ResetCounters();
} }
// See IPullStatsProvider
public string GetStats()
{
return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
SendQueue.Count(),
IncomingPacketQueue.Count,
OutgoingPacketQueue.Count,
ResendOutgoingPacketQueue.Count,
LandOutgoingPacketQueue.Count,
WindOutgoingPacketQueue.Count,
CloudOutgoingPacketQueue.Count,
TaskOutgoingPacketQueue.Count,
TextureOutgoingPacketQueue.Count,
AssetOutgoingPacketQueue.Count);
}
} }
} }

View File

@ -29,6 +29,9 @@
using System; using System;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
@ -38,12 +41,27 @@ namespace OpenSim.Region.ClientStack
{ {
public class PacketServer public class PacketServer
{ {
//private static readonly log4net.ILog m_log private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private ClientStackNetworkHandler m_networkHandler; private ClientStackNetworkHandler m_networkHandler;
private IScene m_scene; private IScene m_scene;
public struct QueuePacket
{
public Packet Packet;
public uint CircuitCode;
public QueuePacket(Packet p, uint c)
{
Packet = p;
CircuitCode = c;
}
}
private List<Thread> Threads = new List<Thread>();
private BlockingQueue<QueuePacket> PacketQueue;
//private readonly ClientManager m_clientManager = new ClientManager(); //private readonly ClientManager m_clientManager = new ClientManager();
//public ClientManager ClientManager //public ClientManager ClientManager
//{ //{
@ -54,6 +72,24 @@ namespace OpenSim.Region.ClientStack
{ {
m_networkHandler = networkHandler; m_networkHandler = networkHandler;
m_networkHandler.RegisterPacketServer(this); m_networkHandler.RegisterPacketServer(this);
PacketQueue = new BlockingQueue<QueuePacket>();
int ThreadCount = 4;
m_log.Debug("[PacketServer]: launching " + ThreadCount.ToString() + " threads.");
for (int x = 0; x < ThreadCount; x++)
{
Thread thread = new Thread(PacketRunner);
thread.IsBackground = true;
thread.Name = "Packet Runner";
thread.Start();
Threads.Add(thread);
}
}
public void Enqueue(uint CircuitCode, Packet packet)
{
IClientAPI client;
PacketQueue.Enqueue(new QueuePacket(packet, CircuitCode));
} }
public IScene LocalScene public IScene LocalScene
@ -61,41 +97,57 @@ namespace OpenSim.Region.ClientStack
set { m_scene = value; } set { m_scene = value; }
} }
/// <summary> private void PacketRunner()
///
/// </summary>
/// <param name="circuitCode"></param>
/// <param name="packet"></param>
public virtual void InPacket(uint circuitCode, Packet packet)
{ {
m_scene.ClientManager.InPacket(circuitCode, packet); while (true)
{
QueuePacket p;
// Mantis 641
lock(PacketQueue)
p = PacketQueue.Dequeue();
if (p.Packet != null)
{
m_scene.ClientManager.InPacket(p.CircuitCode, p.Packet);
}
else
{
m_log.Debug("[PacketServer]: Empty packet from queue!");
}
}
} }
protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, public bool ClaimEndPoint(UseCircuitCodePacket usePacket, EndPoint ep)
ClientManager clientManager, IScene scene, AssetCache assetCache,
PacketServer packServer, AgentCircuitManager authenSessions,
LLUUID agentId, LLUUID sessionId, uint circuitCode)
{ {
return IClientAPI client;
new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode); if (m_scene.ClientManager.TryGetClient(usePacket.CircuitCode.Code, out client))
{
if (client.Claim(ep, usePacket))
{
m_log.Debug("[PacketServer]: Claimed client.");
return true;
}
}
m_log.Debug("[PacketServer]: Failed to claim client.");
return false;
} }
public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, public virtual bool AddNewClient(uint circuitCode, AgentCircuitData agentData
AgentCircuitManager authenticateSessionsClass) , AssetCache assetCache, AgentCircuitManager authenticateSessionsClass)
{ {
m_log.Debug("[PacketServer]: Creating new client for " + circuitCode.ToString());
IClientAPI newuser; IClientAPI newuser;
if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser)) if (m_scene.ClientManager.TryGetClient(circuitCode, out newuser))
{ {
m_log.Debug("[PacketServer]: Already have client for code " + circuitCode.ToString());
return false; return false;
} }
else else
{ {
newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, newuser = new ClientView(m_scene, assetCache, this, authenticateSessionsClass, agentData);
authenticateSessionsClass, useCircuit.CircuitCode.ID,
useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code);
m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); m_scene.ClientManager.Add(circuitCode, newuser);
newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler;
newuser.OnLogout += LogoutHandler; newuser.OnLogout += LogoutHandler;

View File

@ -30,6 +30,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
@ -60,6 +61,9 @@ namespace OpenSim.Region.ClientStack
protected AssetCache m_assetCache; protected AssetCache m_assetCache;
protected AgentCircuitManager m_authenticateSessionsClass; protected AgentCircuitManager m_authenticateSessionsClass;
// temporary queue until I can merge this with userthread rework of packet processing.
protected Queue<Packet> CreateUserPacket = new Queue<Packet>();
public PacketServer PacketServer public PacketServer PacketServer
{ {
get { return m_packetServer; } get { return m_packetServer; }
@ -92,6 +96,7 @@ namespace OpenSim.Region.ClientStack
Allow_Alternate_Port = allow_alternate_port; Allow_Alternate_Port = allow_alternate_port;
m_assetCache = assetCache; m_assetCache = assetCache;
m_authenticateSessionsClass = authenticateClass; m_authenticateSessionsClass = authenticateClass;
m_authenticateSessionsClass.onCircuitAdded += new AgentCircuitManager.CircuitAddedCallback(m_authenticateSessionsClass_onCircuitAdded);
CreatePacketServer(); CreatePacketServer();
// Return new port // Return new port
@ -100,6 +105,16 @@ namespace OpenSim.Region.ClientStack
port = listenPort; port = listenPort;
} }
void m_authenticateSessionsClass_onCircuitAdded(uint circuitCode, AgentCircuitData agentData)
{
m_log.Debug("Got informed of circuit " + circuitCode.ToString() + " for " + agentData.firstname + " " + agentData.lastname
+ " using session ID " + agentData.SessionID.ToString());
// create with afacke endpoint of 0.0.0.0 so that we can tell if it's active and sending packets.
EndPoint ep = new IPEndPoint(IPAddress.Any, 0);
PacketServer.AddNewClient(circuitCode, agentData, m_assetCache, m_authenticateSessionsClass);
}
protected virtual void CreatePacketServer() protected virtual void CreatePacketServer()
{ {
PacketServer packetServer = new PacketServer(this); PacketServer packetServer = new PacketServer(this);
@ -271,38 +286,19 @@ namespace OpenSim.Region.ClientStack
} }
if (ret) if (ret)
{ {
//if so then send packet to the packetserver m_packetServer.Enqueue(circuit, packet);
//m_log.Warn("[UDPSERVER]: ALREADY HAVE Circuit!");
m_packetServer.InPacket(circuit, packet);
} }
else if (packet.Type == PacketType.UseCircuitCode) else if (packet.Type == PacketType.UseCircuitCode)
{ {
// new client // new client
m_log.Debug("[UDPSERVER]: Adding New Client"); m_log.Debug("[UDPSERVER]: Adding New Client");
AddNewClient(packet); AddNewClient(packet, epSender);
}
else
{
// invalid client
//CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now
//m_log.Warn("[UDPSERVER]: Got a packet from an invalid client - " + packet.ToString());
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
m_log.Error("[UDPSERVER]: Exception in processing packet."); m_log.Error("[UDPSERVER]: Exception in processing packet.");
m_log.Debug("[UDPSERVER]: Adding New Client"); m_log.Error("[UDPSERVER]: " + ex.ToString());
try
{
AddNewClient(packet);
}
catch (Exception e3)
{
m_log.Error("[UDPSERVER]: Adding New Client threw exception " + e3.ToString());
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
ReceivedData, null);
}
} }
} }
@ -320,7 +316,7 @@ namespace OpenSim.Region.ClientStack
} }
} }
protected virtual void AddNewClient(Packet packet) protected virtual void AddNewClient(Packet packet, EndPoint epSender)
{ {
UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet;
lock (clientCircuits) lock (clientCircuits)
@ -337,8 +333,7 @@ namespace OpenSim.Region.ClientStack
else else
m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
} }
PacketServer.ClaimEndPoint(useCircuit, epSender);
PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass);
} }
public void ServerListener() public void ServerListener()
@ -384,17 +379,19 @@ namespace OpenSim.Region.ClientStack
} }
public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
//EndPoint packetSender)
{ {
// find the endpoint for this circuit
EndPoint sendto = null; EndPoint sendto = null;
lock (clientCircuits_reverse) lock (clientCircuits_reverse)
{ {
if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
{ {
//we found the endpoint so send the packet to it
Server.SendTo(buffer, size, flags, sendto); Server.SendTo(buffer, size, flags, sendto);
} }
//else
//{
// m_log.Debug("[UDPServer]: Failed to find person to send packet to!");
//}
} }
} }

View File

@ -55,6 +55,8 @@ namespace OpenSim.Region.Communications.Local
public event LoginToRegionEvent OnLoginToRegion; public event LoginToRegionEvent OnLoginToRegion;
private LoginToRegionEvent handler001 = null; // OnLoginToRegion;
public LocalLoginService(UserManagerBase userManager, string welcomeMess, public LocalLoginService(UserManagerBase userManager, string welcomeMess,
CommunicationsLocal parent, NetworkServersInfo serversInfo, CommunicationsLocal parent, NetworkServersInfo serversInfo,
bool authenticate) bool authenticate)
@ -161,9 +163,10 @@ namespace OpenSim.Region.Communications.Local
_login.StartPos = new LLVector3(128, 128, 70); _login.StartPos = new LLVector3(128, 128, 70);
_login.CapsPath = capsPath; _login.CapsPath = capsPath;
if (OnLoginToRegion != null) handler001 = OnLoginToRegion;
if (handler001 != null)
{ {
OnLoginToRegion(currentRegion, _login); handler001(currentRegion, _login);
} }
} }
else else

View File

@ -59,6 +59,13 @@ namespace OpenSim.Region.Communications.OGS1
public event ChildAgentUpdate OnChildAgentUpdate; public event ChildAgentUpdate OnChildAgentUpdate;
public event TellRegionToCloseChildConnection OnTellRegionToCloseChildConnection; public event TellRegionToCloseChildConnection OnTellRegionToCloseChildConnection;
private InformRegionChild handler001 = null; // OnChildAgent;
private ExpectArrival handler002 = null; // OnArrival;
private InformRegionPrimGroup handler003 = null; // OnPrimGroupNear;
private PrimGroupArrival handler004 = null; // OnPrimGroupArrival;
private RegionUp handler005 = null; // OnRegionUp;
private ChildAgentUpdate handler006 = null; // OnChildAgentUpdate;
private TellRegionToCloseChildConnection handler007 = null; // OnTellRegionToCloseChildConnection;
static InterRegionSingleton() static InterRegionSingleton()
@ -76,64 +83,70 @@ namespace OpenSim.Region.Communications.OGS1
public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
{ {
if (OnChildAgent != null) handler001 = OnChildAgent;
if (handler001 != null)
{ {
return OnChildAgent(regionHandle, agentData); return handler001(regionHandle, agentData);
} }
return false; return false;
} }
public bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle) public bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle)
{ {
if (OnRegionUp != null) handler005 = OnRegionUp;
if (handler005 != null)
{ {
return OnRegionUp(sregion, regionhandle); return handler005(sregion, regionhandle);
} }
return false; return false;
} }
public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentUpdate) public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentUpdate)
{ {
if (OnChildAgentUpdate != null) handler006 = OnChildAgentUpdate;
if (handler006 != null)
{ {
return OnChildAgentUpdate(regionHandle, cAgentUpdate); return handler006(regionHandle, cAgentUpdate);
} }
return false; return false;
} }
public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
{ {
if (OnArrival != null) handler002 = OnArrival;
if (handler002 != null)
{ {
return OnArrival(regionHandle, agentID, position, isFlying); return handler002(regionHandle, agentID, position, isFlying);
} }
return false; return false;
} }
public bool InformRegionPrim(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) public bool InformRegionPrim(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical)
{ {
if (OnPrimGroupNear != null) handler003 = OnPrimGroupNear;
if (handler003 != null)
{ {
return OnPrimGroupNear(regionHandle, primID, position, isPhysical); return handler003(regionHandle, primID, position, isPhysical);
} }
return false; return false;
} }
public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, string objData) public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, string objData)
{ {
if (OnPrimGroupArrival != null) handler004 = OnPrimGroupArrival;
if (handler004 != null)
{ {
return OnPrimGroupArrival(regionHandle, primID, objData); return handler004(regionHandle, primID, objData);
} }
return false; return false;
} }
public bool TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) public bool TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID)
{ {
if (OnTellRegionToCloseChildConnection != null) handler007 = OnTellRegionToCloseChildConnection;
if (handler007 != null)
{ {
return handler007(regionHandle, agentID);
return OnTellRegionToCloseChildConnection(regionHandle, agentID);
} }
return false; return false;
} }

View File

@ -42,8 +42,8 @@ namespace OpenSim.Region.Environment.Modules
/// </summary> /// </summary>
public class UserTextureDownloadService public class UserTextureDownloadService
{ {
//private static readonly log4net.ILog m_log private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary> /// <summary>
/// Holds texture senders before they have received the appropriate texture from the asset cache. /// Holds texture senders before they have received the appropriate texture from the asset cache.
@ -138,7 +138,6 @@ namespace OpenSim.Region.Environment.Modules
// this texture could not be found // this texture could not be found
// TODO Send packet back to the client telling it not to expect the texture // TODO Send packet back to the client telling it not to expect the texture
// The absence of this packet doesn't appear to be causing it a problem right now
//m_log.DebugFormat("[USER TEXTURE DOWNLOAD]: Removing download stat for {0}", textureID); //m_log.DebugFormat("[USER TEXTURE DOWNLOAD]: Removing download stat for {0}", textureID);
m_scene.AddPendingDownloads(-1); m_scene.AddPendingDownloads(-1);
@ -150,7 +149,9 @@ namespace OpenSim.Region.Environment.Modules
} }
else else
{ {
throw new Exception("Got a texture with no sender object to handle it, this shouldn't happen"); m_log.WarnFormat(
"Got a texture uuid {0} with no sender object to handle it, this shouldn't happen",
textureID);
} }
} }
} }

View File

@ -47,6 +47,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Events #region Events
public event PhysicsCrash UnRecoverableError; public event PhysicsCrash UnRecoverableError;
private PhysicsCrash handler001 = null;
#endregion #endregion
@ -410,7 +411,7 @@ namespace OpenSim.Region.Environment.Scenes
public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance) public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarAppearance appearance)
{ {
ScenePresence newAvatar = null; ScenePresence newAvatar = null;
m_log.Debug("[InnerScene]: Creating avatar");
newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance); newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, appearance);
newAvatar.IsChildAgent = child; newAvatar.IsChildAgent = child;
@ -715,9 +716,10 @@ namespace OpenSim.Region.Environment.Scenes
public void physicsBasedCrash() public void physicsBasedCrash()
{ {
if (UnRecoverableError != null) handler001 = UnRecoverableError;
if (handler001 != null)
{ {
UnRecoverableError(); handler001();
} }
} }

View File

@ -104,11 +104,16 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
if (((SceneObjectGroup) ent).LocalId == primLocalID) if (((SceneObjectGroup) ent).LocalId == primLocalID)
{
// A prim is only tainted if it's allowed to be edited by the person clicking it.
if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID))
{ {
((SceneObjectGroup) ent).GetProperties(remoteClient); ((SceneObjectGroup) ent).GetProperties(remoteClient);
((SceneObjectGroup) ent).IsSelected = true; ((SceneObjectGroup) ent).IsSelected = true;
LandManager.setPrimsTainted(); LandManager.setPrimsTainted();
}
break; break;
} }
} }
@ -129,6 +134,8 @@ namespace OpenSim.Region.Environment.Scenes
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
if (((SceneObjectGroup) ent).LocalId == primLocalID) if (((SceneObjectGroup) ent).LocalId == primLocalID)
{
if (m_permissionManager.CanEditObjectPosition(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID) || m_permissionManager.CanEditObject(remoteClient.AgentId, ((SceneObjectGroup)ent).UUID))
{ {
((SceneObjectGroup) ent).IsSelected = false; ((SceneObjectGroup) ent).IsSelected = false;
LandManager.setPrimsTainted(); LandManager.setPrimsTainted();
@ -137,6 +144,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
} }
}
public virtual void ProcessMoneyTransferRequest(LLUUID source, LLUUID destination, int amount, int transactiontype, string description) public virtual void ProcessMoneyTransferRequest(LLUUID source, LLUUID destination, int amount, int transactiontype, string description)
{ {

View File

@ -1342,10 +1342,13 @@ namespace OpenSim.Region.Environment.Scenes
m_estateManager.sendRegionHandshake(client); m_estateManager.sendRegionHandshake(client);
m_log.Debug("[SCENE]: Calling CreateScenePresence");
CreateAndAddScenePresence(client, child); CreateAndAddScenePresence(client, child);
m_log.Debug("[SCENE]: Sending parcel overlay");
m_LandManager.sendParcelOverlay(client); m_LandManager.sendParcelOverlay(client);
m_log.Debug("[SCENE]: Adding user to cache.");
CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
m_log.Debug("[SCENE]: Done with adding new user.");
} }
protected virtual void SubscribeToClientEvents(IClientAPI client) protected virtual void SubscribeToClientEvents(IClientAPI client)
@ -1434,7 +1437,7 @@ namespace OpenSim.Region.Environment.Scenes
AvatarAppearance appearance; AvatarAppearance appearance;
GetAvatarAppearance(client, out appearance); GetAvatarAppearance(client, out appearance);
m_log.Debug("[SCENE]: Calling plugin CreateAndAddScenePresence");
avatar = m_innerScene.CreateAndAddScenePresence(client, child, appearance); avatar = m_innerScene.CreateAndAddScenePresence(client, child, appearance);
if (avatar.IsChildAgent) if (avatar.IsChildAgent)

View File

@ -160,7 +160,9 @@ namespace OpenSim.Region.Environment.Scenes
public virtual void Restart(int seconds) public virtual void Restart(int seconds)
{ {
m_log.Error("[REGION]: passing Restart Message up the namespace"); m_log.Error("[REGION]: passing Restart Message up the namespace");
OnRestart(RegionInfo); restart handler001 = OnRestart;
if (handler001 != null)
handler001(RegionInfo);
} }
public virtual bool PresenceChildStatus(LLUUID avatarID) public virtual bool PresenceChildStatus(LLUUID avatarID)

View File

@ -58,7 +58,14 @@ namespace OpenSim.Region.Environment.Scenes
public event ChildAgentUpdate OnChildAgentUpdate; public event ChildAgentUpdate OnChildAgentUpdate;
public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar; public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar;
private AgentCrossing handler001 = null; // OnAvatarCrossingIntoRegion;
private ExpectUserDelegate handler002 = null; // OnExpectUser;
private ExpectPrimDelegate handler003 = null; // OnExpectPrim;
private CloseAgentConnection handler004 = null; // OnCloseAgentConnection;
private PrimCrossing handler005 = null; // OnPrimCrossingIntoRegion;
private RegionUp handler006 = null; // OnRegionUp;
private ChildAgentUpdate handler007 = null; // OnChildAgentUpdate;
private RemoveKnownRegionsFromAvatarList handler008 = null; // OnRemoveKnownRegionFromAvatar;
public KillObjectDelegate KillObject; public KillObjectDelegate KillObject;
public string _debugRegionName = String.Empty; public string _debugRegionName = String.Empty;
@ -125,27 +132,30 @@ namespace OpenSim.Region.Environment.Scenes
/// ///
protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent) protected void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
{ {
if (OnExpectUser != null) handler002 = OnExpectUser;
if (handler002 != null)
{ {
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname); //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
OnExpectUser(regionHandle, agent); handler002(regionHandle, agent);
} }
} }
protected bool newRegionUp(RegionInfo region) protected bool newRegionUp(RegionInfo region)
{ {
if (OnRegionUp != null) handler006 = OnRegionUp;
if (handler006 != null)
{ {
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName); //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
OnRegionUp(region); handler006(region);
} }
return true; return true;
} }
protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
{ {
if (OnChildAgentUpdate != null) handler007 = OnChildAgentUpdate;
OnChildAgentUpdate(regionHandle, cAgentData); if (handler007 != null)
handler007(regionHandle, cAgentData);
return true; return true;
@ -153,36 +163,39 @@ namespace OpenSim.Region.Environment.Scenes
protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) protected void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
{ {
if (OnAvatarCrossingIntoRegion != null) handler001 = OnAvatarCrossingIntoRegion;
if (handler001 != null)
{ {
OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); handler001(regionHandle, agentID, position, isFlying);
} }
} }
protected void IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData) protected void IncomingPrimCrossing(ulong regionHandle, LLUUID primID, String objXMLData)
{ {
if (OnExpectPrim != null) handler003 = OnExpectPrim;
if (handler003 != null)
{ {
OnExpectPrim(regionHandle, primID, objXMLData); handler003(regionHandle, primID, objXMLData);
} }
} }
protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical)
{ {
if (OnPrimCrossingIntoRegion != null) handler005 = OnPrimCrossingIntoRegion;
if (handler005 != null)
{ {
OnPrimCrossingIntoRegion(regionHandle, primID, position, isPhysical); handler005(regionHandle, primID, position, isPhysical);
} }
} }
protected bool CloseConnection(ulong regionHandle, LLUUID agentID) protected bool CloseConnection(ulong regionHandle, LLUUID agentID)
{ {
m_log.Info("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID.ToString()); m_log.Info("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID.ToString());
handler004 = OnCloseAgentConnection;
if (OnCloseAgentConnection != null) if (handler004 != null)
{ {
return OnCloseAgentConnection(regionHandle, agentID); return handler004(regionHandle, agentID);
} }
return false; return false;
} }
@ -424,9 +437,10 @@ namespace OpenSim.Region.Environment.Scenes
// We remove the list of known regions from the agent's known region list through an event // We remove the list of known regions from the agent's known region list through an event
// to scene, because, if an agent logged of, it's likely that there will be no scene presence // to scene, because, if an agent logged of, it's likely that there will be no scene presence
// by the time we get to this part of the method. // by the time we get to this part of the method.
if (OnRemoveKnownRegionFromAvatar != null) handler008 = OnRemoveKnownRegionFromAvatar;
if (handler008 != null)
{ {
OnRemoveKnownRegionFromAvatar(agentID,regionlst); handler008(agentID, regionlst);
} }
} }

View File

@ -158,165 +158,218 @@ namespace OpenSim.Region.Environment.Scenes
public event MoneyTransferEvent OnMoneyTransfer; public event MoneyTransferEvent OnMoneyTransfer;
/* Designated Event Deletage Instances */
private ScriptChangedEvent handler001 = null; //OnScriptChangedEvent;
private ClientMovement handler002 = null; //OnClientMovement;
private OnPermissionErrorDelegate handler003 = null; //OnPermissionError;
private OnPluginConsoleDelegate handler004 = null; //OnPluginConsole;
private OnFrameDelegate handler005 = null; //OnFrame;
private OnNewClientDelegate handler006 = null; //OnNewClient;
private OnNewPresenceDelegate handler007 = null; //OnNewPresence;
private OnRemovePresenceDelegate handler008 = null; //OnRemovePresence;
private OnBackupDelegate handler009 = null; //OnBackup;
private OnParcelPrimCountUpdateDelegate handler010 = null; //OnParcelPrimCountUpdate;
private MoneyTransferEvent handler011 = null; //OnMoneyTransfer;
private OnParcelPrimCountAddDelegate handler012 = null; //OnParcelPrimCountAdd;
private OnShutdownDelegate handler013 = null; //OnShutdown;
private ObjectGrabDelegate handler014 = null; //OnObjectGrab;
private NewRezScript handler015 = null; //OnRezScript;
private RemoveScript handler016 = null; //OnRemoveScript;
private SceneGroupMoved handler017 = null; //OnSceneGroupMove;
private SceneGroupGrabed handler018 = null; //OnSceneGroupGrab;
private LandObjectAdded handler020 = null; //OnLandObjectAdded;
private LandObjectRemoved handler021 = null; //OnLandObjectRemoved;
private AvatarEnteringNewParcel handler022 = null; //OnAvatarEnteringNewParcel;
private NewGridInstantMessage handler023 = null; //OnGridInstantMessageToIMModule;
private NewGridInstantMessage handler024 = null; //OnGridInstantMessageToFriendsModule;
private ClientClosed handler025 = null; //OnClientClosed;
public void TriggerOnScriptChangedEvent(uint localID, uint change) public void TriggerOnScriptChangedEvent(uint localID, uint change)
{ {
if (OnScriptChangedEvent != null) handler001 = OnScriptChangedEvent;
OnScriptChangedEvent(localID,change); if (handler001 != null)
handler001(localID, change);
} }
public void TriggerOnClientMovement(ScenePresence avatar) public void TriggerOnClientMovement(ScenePresence avatar)
{ {
if (OnClientMovement != null) handler002 = OnClientMovement;
OnClientMovement(avatar); if (handler002 != null)
handler002(avatar);
} }
public void TriggerPermissionError(LLUUID user, string reason) public void TriggerPermissionError(LLUUID user, string reason)
{ {
if (OnPermissionError != null) handler003 = OnPermissionError;
OnPermissionError(user, reason); if (handler003 != null)
handler003(user, reason);
} }
public void TriggerOnPluginConsole(string[] args) public void TriggerOnPluginConsole(string[] args)
{ {
if (OnPluginConsole != null) handler004 = OnPluginConsole;
OnPluginConsole(args); if (handler004 != null)
handler004(args);
} }
public void TriggerOnFrame() public void TriggerOnFrame()
{ {
if (OnFrame != null) handler005 = OnFrame;
if (handler005 != null)
{ {
OnFrame(); handler005();
} }
} }
public void TriggerOnNewClient(IClientAPI client) public void TriggerOnNewClient(IClientAPI client)
{ {
if (OnNewClient != null) handler006 = OnNewClient;
OnNewClient(client); if (handler006 != null)
handler006(client);
} }
public void TriggerOnNewPresence(ScenePresence presence) public void TriggerOnNewPresence(ScenePresence presence)
{ {
if (OnNewPresence != null) handler007 = OnNewPresence;
OnNewPresence(presence); if (handler007 != null)
handler007(presence);
} }
public void TriggerOnRemovePresence(LLUUID agentId) public void TriggerOnRemovePresence(LLUUID agentId)
{ {
if (OnRemovePresence != null) handler008 = OnRemovePresence;
if (handler008 != null)
{ {
OnRemovePresence(agentId); handler008(agentId);
} }
} }
public void TriggerOnBackup(IRegionDataStore dstore) public void TriggerOnBackup(IRegionDataStore dstore)
{ {
if (OnBackup != null) handler009 = OnBackup;
if (handler009 != null)
{ {
OnBackup(dstore); handler009(dstore);
} }
} }
public void TriggerParcelPrimCountUpdate() public void TriggerParcelPrimCountUpdate()
{ {
if (OnParcelPrimCountUpdate != null) handler010 = OnParcelPrimCountUpdate;
if (handler010 != null)
{ {
OnParcelPrimCountUpdate(); handler010();
} }
} }
public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e) public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs e)
{ {
if (OnMoneyTransfer != null) handler011 = OnMoneyTransfer;
if (handler011 != null)
{ {
OnMoneyTransfer(sender, e); handler011(sender, e);
} }
} }
public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
{ {
if (OnParcelPrimCountAdd != null) handler012 = OnParcelPrimCountAdd;
if (handler012 != null)
{ {
OnParcelPrimCountAdd(obj); handler012(obj);
} }
} }
public void TriggerShutdown() public void TriggerShutdown()
{ {
if (OnShutdown != null) handler013 = OnShutdown;
OnShutdown(); if (handler013 != null)
handler013();
} }
public void TriggerObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) public void TriggerObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
{ {
if (OnObjectGrab != null) handler014 = OnObjectGrab;
if (handler014 != null)
{ {
OnObjectGrab(localID, offsetPos, remoteClient); handler014(localID, offsetPos, remoteClient);
} }
} }
public void TriggerRezScript(uint localID, LLUUID itemID, string script) public void TriggerRezScript(uint localID, LLUUID itemID, string script)
{ {
if (OnRezScript != null) handler015 = OnRezScript;
if (handler015 != null)
{ {
OnRezScript(localID, itemID, script); handler015(localID, itemID, script);
} }
} }
public void TriggerRemoveScript(uint localID, LLUUID itemID) public void TriggerRemoveScript(uint localID, LLUUID itemID)
{ {
if (OnRemoveScript != null) handler016 = OnRemoveScript;
if (handler016 != null)
{ {
OnRemoveScript(localID, itemID); handler016(localID, itemID);
} }
} }
public bool TriggerGroupMove(LLUUID groupID, LLVector3 delta) public bool TriggerGroupMove(LLUUID groupID, LLVector3 delta)
{ {
if (OnSceneGroupMove != null) handler017 = OnSceneGroupMove;
if (handler017 != null)
{ {
return OnSceneGroupMove(groupID, delta); return handler017(groupID, delta);
} }
return true; return true;
} }
public void TriggerGroupGrab(LLUUID groupID, LLVector3 offset, LLUUID userID) public void TriggerGroupGrab(LLUUID groupID, LLVector3 offset, LLUUID userID)
{ {
if (OnSceneGroupGrab != null) handler018 = OnSceneGroupGrab;
if (handler018 != null)
{ {
OnSceneGroupGrab(groupID, offset, userID); handler018(groupID, offset, userID);
} }
} }
public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID) public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID)
{ {
if (OnLandObjectAdded != null) handler020 = OnLandObjectAdded;
if (handler020 != null)
{ {
OnLandObjectAdded(newParcel, regionID); handler020(newParcel, regionID);
} }
} }
public void TriggerLandObjectRemoved(LLUUID globalID) public void TriggerLandObjectRemoved(LLUUID globalID)
{ {
if (OnLandObjectRemoved != null) handler021 = OnLandObjectRemoved;
if (handler021 != null)
{ {
OnLandObjectRemoved(globalID); handler021(globalID);
} }
} }
public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel) public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel)
{ {
//triggerLandObjectRemoved(localParcelID); //triggerLandObjectRemoved(localParcelID);
TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID); TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID);
} }
public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID) public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
{ {
if (OnAvatarEnteringNewParcel != null) handler022 = OnAvatarEnteringNewParcel;
if (handler022 != null)
{ {
OnAvatarEnteringNewParcel(avatar, localLandID, regionID); handler022(avatar, localLandID, regionID);
} }
} }
@ -327,17 +380,18 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if ((whichModule & InstantMessageReceiver.IMModule) != 0) if ((whichModule & InstantMessageReceiver.IMModule) != 0)
{ {
handler023 = OnGridInstantMessageToIMModule;
if (OnGridInstantMessageToIMModule != null) if (handler023 != null)
{ {
OnGridInstantMessageToIMModule(message); handler023(message);
} }
} }
if ((whichModule & InstantMessageReceiver.FriendsModule) != 0) if ((whichModule & InstantMessageReceiver.FriendsModule) != 0)
{ {
if (OnGridInstantMessageToFriendsModule != null) handler024 = OnGridInstantMessageToFriendsModule;
if (handler024 != null)
{ {
OnGridInstantMessageToFriendsModule(message); handler024(message);
} }
} }
@ -345,9 +399,10 @@ namespace OpenSim.Region.Environment.Scenes
public void TriggerClientClosed(LLUUID ClientID) public void TriggerClientClosed(LLUUID ClientID)
{ {
if (OnClientClosed != null) handler025 = OnClientClosed;
if (handler025 != null)
{ {
OnClientClosed(ClientID); handler025(ClientID);
} }
} }

View File

@ -54,6 +54,7 @@ namespace OpenSim.Region.Environment.Scenes
protected ulong m_regionHandle; protected ulong m_regionHandle;
public event PrimCountTaintedDelegate OnPrimCountTainted; public event PrimCountTaintedDelegate OnPrimCountTainted;
private PrimCountTaintedDelegate handler001 = null;
/// <summary> /// <summary>
/// Signal whether the non-inventory attributes of any prims in the group have changed /// Signal whether the non-inventory attributes of any prims in the group have changed
@ -202,6 +203,14 @@ namespace OpenSim.Region.Environment.Scenes
if (m_rootPart.PhysActor != null) if (m_rootPart.PhysActor != null)
{ {
m_rootPart.PhysActor.Selected = value; m_rootPart.PhysActor.Selected = value;
// Pass it on to the children.
foreach (SceneObjectPart child in Children.Values)
{
if (child.PhysActor != null)
{
child.PhysActor.Selected = value;
}
}
} }
} }
} }
@ -1525,9 +1534,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void TriggerTainted() public void TriggerTainted()
{ {
if (OnPrimCountTainted != null) handler001 = OnPrimCountTainted;
if (handler001 != null)
{ {
OnPrimCountTainted(); handler001();
} }
} }

View File

@ -116,6 +116,8 @@ namespace OpenSim.Region.Environment.Scenes
private readonly List<ulong> m_knownChildRegions = new List<ulong>(); private readonly List<ulong> m_knownChildRegions = new List<ulong>();
//neighbouring regions we have enabled a child agent in //neighbouring regions we have enabled a child agent in
private SignificantClientMovement handler001 = null; //OnSignificantClientMovement;
/// <summary> /// <summary>
/// Implemented Control Flags /// Implemented Control Flags
@ -1482,9 +1484,10 @@ namespace OpenSim.Region.Environment.Scenes
if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5)
{ {
posLastSignificantMove = AbsolutePosition; posLastSignificantMove = AbsolutePosition;
if (OnSignificantClientMovement != null)
if (handler001 != null)
{ {
OnSignificantClientMovement(m_controllingClient); handler001(m_controllingClient);
m_scene.NotifyMyCoarseLocationChange(); m_scene.NotifyMyCoarseLocationChange();
} }
} }

View File

@ -39,6 +39,8 @@ namespace OpenSim.Region.Environment.Scenes
public event SendStatResult OnSendStatsResult; public event SendStatResult OnSendStatsResult;
private SendStatResult handler001 = null;
private enum Stats : uint private enum Stats : uint
{ {
TimeDilation = 0, TimeDilation = 0,
@ -245,9 +247,10 @@ namespace OpenSim.Region.Environment.Scenes
statpack.Stat = sb; statpack.Stat = sb;
if (OnSendStatsResult != null) handler001 = OnSendStatsResult;
if (handler001 != null)
{ {
OnSendStatsResult(statpack); handler001(statpack);
} }
resetvalues(); resetvalues();
m_report.Enabled = true; m_report.Enabled = true;

View File

@ -158,6 +158,11 @@ namespace SimpleApp
private LLUUID myID = LLUUID.Random(); private LLUUID myID = LLUUID.Random();
public bool Claim(EndPoint ep, UseCircuitCodePacket packet)
{
throw new Exception("Unimplemented!");
}
public MyNpcCharacter(EventManager eventManager) public MyNpcCharacter(EventManager eventManager)
{ {
// startPos = new LLVector3(128, (float)(Util.RandomClass.NextDouble()*100), 2); // startPos = new LLVector3(128, (float)(Util.RandomClass.NextDouble()*100), 2);
@ -204,6 +209,11 @@ namespace SimpleApp
get { return FirstName + LastName; } get { return FirstName + LastName; }
} }
public EndPoint EndPoint
{
get { throw new Exception("Unimplemented.");}
set { throw new Exception("Unimplemented.");}
}
public virtual void OutPacket(Packet newPack, ThrottleOutPacketType packType) public virtual void OutPacket(Packet newPack, ThrottleOutPacketType packType)
{ {

View File

@ -228,6 +228,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }

View File

@ -895,6 +895,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }

View File

@ -124,6 +124,8 @@ namespace OpenSim.Region.Physics.Manager
public abstract PrimitiveBaseShape Shape { set; } public abstract PrimitiveBaseShape Shape { set; }
public abstract uint LocalID { set; }
public abstract bool Grabbed { set; } public abstract bool Grabbed { set; }
public abstract bool Selected { set; } public abstract bool Selected { set; }
@ -228,6 +230,11 @@ namespace OpenSim.Region.Physics.Manager
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }

View File

@ -87,6 +87,8 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_hackSentFall = false; private bool m_hackSentFall = false;
private bool m_hackSentFly = false; private bool m_hackSentFly = false;
private bool m_foundDebian = false; private bool m_foundDebian = false;
public uint m_localID = 0;
private CollisionLocker ode; private CollisionLocker ode;
private string m_name = String.Empty; private string m_name = String.Empty;
@ -94,6 +96,15 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool[] m_colliderarr = new bool[11]; private bool[] m_colliderarr = new bool[11];
private bool[] m_colliderGroundarr = new bool[11]; private bool[] m_colliderGroundarr = new bool[11];
// Default we're a Character
private CollisionCategories m_collisionCategories = (CollisionCategories.Character);
// Default, Collide with Other Geometries, spaces, bodies and characters.
private CollisionCategories m_collisionFlags = (CollisionCategories.Geom
| CollisionCategories.Space
| CollisionCategories.Body
| CollisionCategories.Character
| CollisionCategories.Land);
private bool jumping = false; private bool jumping = false;
//private float gravityAccel; //private float gravityAccel;
@ -157,6 +168,11 @@ namespace OpenSim.Region.Physics.OdePlugin
set { m_alwaysRun = value; } set { m_alwaysRun = value; }
} }
public override uint LocalID
{
set { m_localID = value; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }
@ -404,6 +420,10 @@ namespace OpenSim.Region.Physics.OdePlugin
int dAMotorEuler = 1; int dAMotorEuler = 1;
_parent_scene.waitForSpaceUnlock(_parent_scene.space); _parent_scene.waitForSpaceUnlock(_parent_scene.space);
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
Body = d.BodyCreate(_parent_scene.world); Body = d.BodyCreate(_parent_scene.world);
d.BodySetPosition(Body, npositionX, npositionY, npositionZ); d.BodySetPosition(Body, npositionX, npositionY, npositionZ);

View File

@ -52,12 +52,30 @@ namespace OpenSim.Region.Physics.OdePlugin
private PhysicsVector m_taintsize; private PhysicsVector m_taintsize;
private PhysicsVector m_taintVelocity = PhysicsVector.Zero; private PhysicsVector m_taintVelocity = PhysicsVector.Zero;
private Quaternion m_taintrot; private Quaternion m_taintrot;
private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
| CollisionCategories.Space
| CollisionCategories.Body
| CollisionCategories.Character);
private bool m_taintshape = false; private bool m_taintshape = false;
private bool m_taintPhysics = false; private bool m_taintPhysics = false;
private bool m_collidesLand = true;
private bool m_collidesWater = false;
// Default we're a Geometry
private CollisionCategories m_collisionCategories = (CollisionCategories.Geom );
// Default, Collide with Other Geometries, spaces and Bodies
private CollisionCategories m_collisionFlags = m_default_collisionFlags;
public bool m_taintremove = false; public bool m_taintremove = false;
public bool m_taintdisable = false; public bool m_taintdisable = false;
public bool m_disabled = false; public bool m_disabled = false;
public bool m_taintadd = false; public bool m_taintadd = false;
public bool m_taintselected = false;
public uint m_localID = 0;
public GCHandle gc; public GCHandle gc;
private CollisionLocker ode; private CollisionLocker ode;
@ -74,6 +92,8 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool iscolliding = false; private bool iscolliding = false;
private bool m_isphysical = false; private bool m_isphysical = false;
private bool m_isSelected = false;
private bool m_throttleUpdates = false; private bool m_throttleUpdates = false;
private int throttleCounter = 0; private int throttleCounter = 0;
public int m_interpenetrationcount = 0; public int m_interpenetrationcount = 0;
@ -172,6 +192,11 @@ namespace OpenSim.Region.Physics.OdePlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { m_localID = value; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }
@ -179,17 +204,59 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool Selected public override bool Selected
{ {
set { return; } set {
// This only makes the object not collidable if the object
// is physical or the object is modified somehow *IN THE FUTURE*
// without this, if an avatar selects prim, they can walk right
// through it while it's selected
if ((m_isphysical && !_zeroFlag) || !value)
{
m_taintselected = value;
_parent_scene.AddPhysicsActorTaint(this);
}
else
{
m_taintselected = value;
m_isSelected = value;
}
}
} }
public void SetGeom(IntPtr geom) public void SetGeom(IntPtr geom)
{ {
prev_geom = prim_geom; prev_geom = prim_geom;
prim_geom = geom; prim_geom = geom;
if (prim_geom != (IntPtr)0)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
//m_log.Warn("Setting Geom to: " + prim_geom); //m_log.Warn("Setting Geom to: " + prim_geom);
} }
public void enableBodySoft()
{
if (m_isphysical)
if (Body != (IntPtr)0)
d.BodyEnable(Body);
m_disabled = false;
}
public void disableBodySoft()
{
m_disabled = true;
if (m_isphysical)
if (Body != (IntPtr)0)
d.BodyDisable(Body);
}
public void enableBody() public void enableBody()
{ {
// Sets the geom to a body // Sets the geom to a body
@ -204,6 +271,13 @@ namespace OpenSim.Region.Physics.OdePlugin
myrot.Z = _orientation.z; myrot.Z = _orientation.z;
d.BodySetQuaternion(Body, ref myrot); d.BodySetQuaternion(Body, ref myrot);
d.GeomSetBody(prim_geom, Body); d.GeomSetBody(prim_geom, Body);
m_collisionCategories |= CollisionCategories.Body;
m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
d.BodySetAutoDisableFlag(Body, true); d.BodySetAutoDisableFlag(Body, true);
d.BodySetAutoDisableSteps(Body, 20); d.BodySetAutoDisableSteps(Body, 20);
@ -332,6 +406,15 @@ namespace OpenSim.Region.Physics.OdePlugin
//this kills the body so things like 'mesh' can re-create it. //this kills the body so things like 'mesh' can re-create it.
if (Body != (IntPtr) 0) if (Body != (IntPtr) 0)
{ {
m_collisionCategories &= ~CollisionCategories.Body;
m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
if (prim_geom != (IntPtr)0)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
_parent_scene.remActivePrim(this); _parent_scene.remActivePrim(this);
d.BodyDestroy(Body); d.BodyDestroy(Body);
Body = (IntPtr) 0; Body = (IntPtr) 0;
@ -425,10 +508,81 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_taintdisable) if (m_taintdisable)
changedisable(timestep); changedisable(timestep);
if (m_taintselected != m_isSelected)
changeSelectedStatus(timestep);
if (m_taintVelocity != PhysicsVector.Zero) if (m_taintVelocity != PhysicsVector.Zero)
changevelocity(timestep); changevelocity(timestep);
} }
private void changeSelectedStatus(float timestep)
{
while (ode.lockquery())
{
}
ode.dlock(_parent_scene.world);
if (m_taintselected)
{
m_collisionCategories = CollisionCategories.Selected;
m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space);
// We do the body disable soft twice because 'in theory' a collision could have happened
// in between the disabling and the collision properties setting
// which would wake the physical body up from a soft disabling and potentially cause it to fall
// through the ground.
if (m_isphysical)
{
disableBodySoft();
}
if (prim_geom != (IntPtr)0)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
if (m_isphysical)
{
disableBodySoft();
}
}
else
{
m_collisionCategories = CollisionCategories.Geom;
if (m_isphysical)
m_collisionCategories |= CollisionCategories.Body;
m_collisionFlags = m_default_collisionFlags;
if (m_collidesLand)
m_collisionFlags |= CollisionCategories.Land;
if (m_collidesWater)
m_collisionFlags |= CollisionCategories.Water;
if (prim_geom != (IntPtr)0)
{
d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
}
if (m_isphysical)
enableBodySoft();
}
ode.dunlock(_parent_scene.world);
resetCollisionAccounting();
m_isSelected = m_taintselected;
}
public void ResetTaints() public void ResetTaints()
{ {
@ -438,6 +592,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintPhysics = m_isphysical; m_taintPhysics = m_isphysical;
m_taintselected = m_isSelected;
m_taintsize = _size; m_taintsize = _size;
@ -586,6 +742,9 @@ namespace OpenSim.Region.Physics.OdePlugin
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
_parent_scene.geom_name_map[prim_geom] = this.m_primName; _parent_scene.geom_name_map[prim_geom] = this.m_primName;
_parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this;
changeSelectedStatus(timestep);
m_taintadd = false; m_taintadd = false;
@ -630,6 +789,8 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
changeSelectedStatus(timestep);
resetCollisionAccounting(); resetCollisionAccounting();
m_taintposition = _position; m_taintposition = _position;
} }
@ -682,7 +843,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_taintdisable = false; m_taintdisable = false;
} }
public void changePhysicsStatus(float timestap) public void changePhysicsStatus(float timestep)
{ {
lock (ode) lock (ode)
{ {
@ -709,6 +870,8 @@ namespace OpenSim.Region.Physics.OdePlugin
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
} }
changeSelectedStatus(timestep);
resetCollisionAccounting(); resetCollisionAccounting();
m_taintPhysics = m_isphysical; m_taintPhysics = m_isphysical;
} }
@ -880,6 +1043,8 @@ namespace OpenSim.Region.Physics.OdePlugin
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
changeSelectedStatus(timestamp);
resetCollisionAccounting(); resetCollisionAccounting();
m_taintsize = _size; m_taintsize = _size;
} }
@ -927,7 +1092,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// Re creates body on size. // Re creates body on size.
// EnableBody also does setMass() // EnableBody also does setMass()
enableBody(); enableBody();
d.BodyEnable(Body);
} }
} }
else else
@ -1032,15 +1197,21 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodyEnable(Body); d.BodyEnable(Body);
} }
} }
_parent_scene.geom_name_map[prim_geom] = oldname; _parent_scene.geom_name_map[prim_geom] = oldname;
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
changeSelectedStatus(timestamp);
resetCollisionAccounting(); resetCollisionAccounting();
m_taintshape = false; m_taintshape = false;
} }
public void changeAddForce(float timestamp) public void changeAddForce(float timestamp)
{
if (!m_isSelected)
{ {
while (ode.lockquery()) while (ode.lockquery())
{ {
@ -1068,10 +1239,13 @@ namespace OpenSim.Region.Physics.OdePlugin
m_collisionscore = 0; m_collisionscore = 0;
m_interpenetrationcount = 0; m_interpenetrationcount = 0;
}
m_taintforce = false; m_taintforce = false;
} }
private void changevelocity(float timestep) private void changevelocity(float timestep)
{
if (!m_isSelected)
{ {
lock (ode) lock (ode)
{ {
@ -1092,6 +1266,7 @@ namespace OpenSim.Region.Physics.OdePlugin
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
} }
//resetCollisionAccounting(); //resetCollisionAccounting();
}
m_taintVelocity = PhysicsVector.Zero; m_taintVelocity = PhysicsVector.Zero;
} }
public override bool IsPhysical public override bool IsPhysical
@ -1275,6 +1450,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
PhysicsVector pv = new PhysicsVector(0, 0, 0); PhysicsVector pv = new PhysicsVector(0, 0, 0);
bool lastZeroFlag = _zeroFlag;
if (Body != (IntPtr) 0) if (Body != (IntPtr) 0)
{ {
d.Vector3 vec = d.BodyGetPosition(Body); d.Vector3 vec = d.BodyGetPosition(Body);
@ -1371,6 +1547,9 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
if (lastZeroFlag != _zeroFlag)
base.RequestPhysicsterseUpdate();
m_lastVelocity = _velocity; m_lastVelocity = _velocity;
_position = l_position; _position = l_position;

View File

@ -78,6 +78,21 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
[Flags]
public enum CollisionCategories : int
{
Disabled = 0,
Geom = 0x00000001,
Body = 0x00000002,
Space = 0x00000004,
Character = 0x00000008,
Land = 0x00000010,
Water = 0x00000020,
Wind = 0x00000040,
Sensor = 0x00000080,
Selected = 0x00000100
}
public class OdeScene : PhysicsScene public class OdeScene : PhysicsScene
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@ -997,6 +1012,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// creating a new space for prim and inserting it into main space. // creating a new space for prim and inserting it into main space.
staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero);
d.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space);
waitForSpaceUnlock(space); waitForSpaceUnlock(space);
d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]);
return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY];
@ -1656,6 +1672,12 @@ namespace OpenSim.Region.Physics.OdePlugin
offset, thickness, wrap); offset, thickness, wrap);
d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
LandGeom = d.CreateHeightfield(space, HeightmapData, 1); LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
if (LandGeom != (IntPtr)0)
{
d.GeomSetCategoryBits(LandGeom, (int)(CollisionCategories.Land));
d.GeomSetCollideBits(LandGeom, (int)(CollisionCategories.Space));
}
geom_name_map[LandGeom] = "Terrain"; geom_name_map[LandGeom] = "Terrain";
d.Matrix3 R = new d.Matrix3(); d.Matrix3 R = new d.Matrix3();

View File

@ -357,6 +357,11 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }
@ -645,6 +650,11 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }

View File

@ -227,6 +227,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }
@ -437,6 +442,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
set { return; } set { return; }
} }
public override uint LocalID
{
set { return; }
}
public override bool Grabbed public override bool Grabbed
{ {
set { return; } set { return; }

View File

@ -41,8 +41,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// </summary> /// </summary>
public class AsyncLSLCommandManager : iScriptEngineFunctionModule public class AsyncLSLCommandManager : iScriptEngineFunctionModule
{ {
private Thread cmdHandlerThread; private static Thread cmdHandlerThread;
private int cmdHandlerThreadCycleSleepms; private static int cmdHandlerThreadCycleSleepms;
private ScriptEngine m_ScriptEngine; private ScriptEngine m_ScriptEngine;
@ -51,18 +51,26 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
m_ScriptEngine = _ScriptEngine; m_ScriptEngine = _ScriptEngine;
ReadConfig(); ReadConfig();
StartThread();
}
private void StartThread()
{
if (cmdHandlerThread == null)
{
// Start the thread that will be doing the work // Start the thread that will be doing the work
cmdHandlerThread = new Thread(CmdHandlerThreadLoop); cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
cmdHandlerThread.Name = "CmdHandlerThread"; cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
cmdHandlerThread.Priority = ThreadPriority.BelowNormal; cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
cmdHandlerThread.IsBackground = true; cmdHandlerThread.IsBackground = true;
cmdHandlerThread.Start(); cmdHandlerThread.Start();
OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread); OpenSim.Framework.ThreadTracker.Add(cmdHandlerThread);
} }
}
public void ReadConfig() public void ReadConfig()
{ {
cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 50); cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
} }
~AsyncLSLCommandManager() ~AsyncLSLCommandManager()
@ -84,33 +92,49 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
} }
private void CmdHandlerThreadLoop() private static void CmdHandlerThreadLoop()
{ {
while (true) while (true)
{ {
// Check timers try
CheckTimerEvents(); {
Thread.Sleep(25); while (true)
// Check HttpRequests {
CheckHttpRequests(); Thread.Sleep(cmdHandlerThreadCycleSleepms);
Thread.Sleep(25); //lock (ScriptEngine.ScriptEngines)
// Check XMLRPCRequests //{
CheckXMLRPCRequests(); foreach (ScriptEngine se in new ArrayList(ScriptEngine.ScriptEngines))
Thread.Sleep(25); {
// Check Listeners se.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
CheckListeners(); }
Thread.Sleep(25); //}
// Sleep before next cycle // Sleep before next cycle
//Thread.Sleep(cmdHandlerThreadCycleSleepms); //Thread.Sleep(cmdHandlerThreadCycleSleepms);
} }
} }
catch
{
}
}
}
internal void DoOneCmdHandlerPass()
{
// Check timers
CheckTimerEvents();
// Check HttpRequests
CheckHttpRequests();
// Check XMLRPCRequests
CheckXMLRPCRequests();
// Check Listeners
CheckListeners();
}
/// <summary> /// <summary>
/// Remove a specific script (and all its pending commands) /// Remove a specific script (and all its pending commands)
/// </summary> /// </summary>
/// <param name="m_localID"></param> /// <param name="localID"></param>
/// <param name="m_itemID"></param> /// <param name="itemID"></param>
public void RemoveScript(uint localID, LLUUID itemID) public void RemoveScript(uint localID, LLUUID itemID)
{ {
// Remove a specific script // Remove a specific script

View File

@ -45,7 +45,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public class EventQueueManager : iScriptEngineFunctionModule public class EventQueueManager : iScriptEngineFunctionModule
{ {
// //
// Class is instanced in "ScriptEngine" and used by "EventManager" also instanced in "ScriptEngine". // Class is instanced in "ScriptEngine" and used by "EventManager" which is also instanced in "ScriptEngine".
// //
// Class purpose is to queue and execute functions that are received by "EventManager": // Class purpose is to queue and execute functions that are received by "EventManager":
// - allowing "EventManager" to release its event thread immediately, thus not interrupting server execution. // - allowing "EventManager" to release its event thread immediately, thus not interrupting server execution.
@ -68,25 +68,25 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// List of threads (classes) processing event queue /// List of threads (classes) processing event queue
/// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting. /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
/// </summary> /// </summary>
internal List<EventQueueThreadClass> eventQueueThreads; // Thread pool that we work on internal static List<EventQueueThreadClass> eventQueueThreads = new List<EventQueueThreadClass>(); // Thread pool that we work on
/// <summary> /// <summary>
/// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads. /// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads.
/// </summary> /// </summary>
// private object eventQueueThreadsLock = new object(); // private object eventQueueThreadsLock = new object();
// Static objects for referencing the objects above if we don't have private threads: // Static objects for referencing the objects above if we don't have private threads:
internal static List<EventQueueThreadClass> staticEventQueueThreads; // A static reference used if we don't use private threads //internal static List<EventQueueThreadClass> staticEventQueueThreads; // A static reference used if we don't use private threads
// internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason // internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason
/// <summary> /// <summary>
/// Global static list of all threads (classes) processing event queue -- used by max enforcment thread /// Global static list of all threads (classes) processing event queue -- used by max enforcment thread
/// </summary> /// </summary>
private List<EventQueueThreadClass> staticGlobalEventQueueThreads = new List<EventQueueThreadClass>(); //private List<EventQueueThreadClass> staticGlobalEventQueueThreads = new List<EventQueueThreadClass>();
/// <summary> /// <summary>
/// Used internally to specify how many threads should exit gracefully /// Used internally to specify how many threads should exit gracefully
/// </summary> /// </summary>
public int ThreadsToExit; public static int ThreadsToExit;
public object ThreadsToExitLock = new object(); public static object ThreadsToExitLock = new object();
//public object queueLock = new object(); // Mutex lock object //public object queueLock = new object(); // Mutex lock object
@ -94,14 +94,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <summary> /// <summary>
/// How many threads to process queue with /// How many threads to process queue with
/// </summary> /// </summary>
internal int numberOfThreads; internal static int numberOfThreads;
internal static int EventExecutionMaxQueueSize; internal static int EventExecutionMaxQueueSize;
/// <summary> /// <summary>
/// Maximum time one function can use for execution before we perform a thread kill. /// Maximum time one function can use for execution before we perform a thread kill.
/// </summary> /// </summary>
private int maxFunctionExecutionTimems private static int maxFunctionExecutionTimems
{ {
get { return (int)(maxFunctionExecutionTimens / 10000); } get { return (int)(maxFunctionExecutionTimens / 10000); }
set { maxFunctionExecutionTimens = value * 10000; } set { maxFunctionExecutionTimens = value * 10000; }
@ -111,15 +111,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// Contains nanoseconds version of maxFunctionExecutionTimems so that it matches time calculations better (performance reasons). /// Contains nanoseconds version of maxFunctionExecutionTimems so that it matches time calculations better (performance reasons).
/// WARNING! ONLY UPDATE maxFunctionExecutionTimems, NEVER THIS DIRECTLY. /// WARNING! ONLY UPDATE maxFunctionExecutionTimems, NEVER THIS DIRECTLY.
/// </summary> /// </summary>
public long maxFunctionExecutionTimens; public static long maxFunctionExecutionTimens;
/// <summary> /// <summary>
/// Enforce max execution time /// Enforce max execution time
/// </summary> /// </summary>
public bool EnforceMaxExecutionTime; public static bool EnforceMaxExecutionTime;
/// <summary> /// <summary>
/// Kill script (unload) when it exceeds execution time /// Kill script (unload) when it exceeds execution time
/// </summary> /// </summary>
private bool KillScriptOnMaxFunctionExecutionTime; private static bool KillScriptOnMaxFunctionExecutionTime;
/// <summary> /// <summary>
/// List of localID locks for mutex processing of script events /// List of localID locks for mutex processing of script events
@ -172,33 +172,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{ {
m_ScriptEngine = _ScriptEngine; m_ScriptEngine = _ScriptEngine;
// TODO: We need to move from single EventQueueManager to list of it in to share threads
bool PrivateRegionThreads = true; // m_ScriptEngine.ScriptConfigSource.GetBoolean("PrivateRegionThreads", false);
// Create thread pool list and lock object
// Determine from config if threads should be dedicated to regions or shared
if (PrivateRegionThreads)
{
// PRIVATE THREAD POOL PER REGION
eventQueueThreads = new List<EventQueueThreadClass>();
// eventQueueThreadsLock = new object();
}
else
{
// SHARED THREAD POOL
// Crate the static objects
if (staticEventQueueThreads == null)
staticEventQueueThreads = new List<EventQueueThreadClass>();
// if (staticEventQueueThreadsLock == null)
// staticEventQueueThreadsLock = new object();
// Now reference our locals to them
eventQueueThreads = staticEventQueueThreads;
//eventQueueThreadsLock = staticEventQueueThreadsLock;
}
ReadConfig(); ReadConfig();
AdjustNumberOfScriptThreads();
} }
public void ReadConfig() public void ReadConfig()
@ -230,18 +205,18 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
private void Stop() private void Stop()
{ {
if (eventQueueThreads != null && eventQueueThreads != null) if (eventQueueThreads != null)
{ {
// Kill worker threads // Kill worker threads
//lock (eventQueueThreads) lock (eventQueueThreads)
//{ {
foreach (EventQueueThreadClass EventQueueThread in new ArrayList(eventQueueThreads)) foreach (EventQueueThreadClass EventQueueThread in new ArrayList(eventQueueThreads))
{ {
AbortThreadClass(EventQueueThread); AbortThreadClass(EventQueueThread);
} }
//eventQueueThreads.Clear(); //eventQueueThreads.Clear();
//staticGlobalEventQueueThreads.Clear(); //staticGlobalEventQueueThreads.Clear();
//} }
} }
// Remove all entries from our event queue // Remove all entries from our event queue
@ -256,9 +231,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
#region " Start / stop script execution threads (ThreadClasses) " #region " Start / stop script execution threads (ThreadClasses) "
private void StartNewThreadClass() private void StartNewThreadClass()
{ {
EventQueueThreadClass eqtc = new EventQueueThreadClass(this); EventQueueThreadClass eqtc = new EventQueueThreadClass();
eventQueueThreads.Add(eqtc); eventQueueThreads.Add(eqtc);
staticGlobalEventQueueThreads.Add(eqtc);
m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Started new script execution thread. Current thread count: " + eventQueueThreads.Count); m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Started new script execution thread. Current thread count: " + eventQueueThreads.Count);
} }
@ -266,8 +240,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{ {
if (eventQueueThreads.Contains(threadClass)) if (eventQueueThreads.Contains(threadClass))
eventQueueThreads.Remove(threadClass); eventQueueThreads.Remove(threadClass);
if (staticGlobalEventQueueThreads.Contains(threadClass))
staticGlobalEventQueueThreads.Remove(threadClass);
try try
{ {
@ -426,7 +398,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// Iterate through all ScriptThreadClasses and check how long their current function has been executing // Iterate through all ScriptThreadClasses and check how long their current function has been executing
lock (eventQueueThreads) lock (eventQueueThreads)
{ {
foreach (EventQueueThreadClass EventQueueThread in staticGlobalEventQueueThreads) foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
{ {
// Is thread currently executing anything? // Is thread currently executing anything?
if (EventQueueThread.InExecution) if (EventQueueThread.InExecution)
@ -452,14 +424,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
#endregion #endregion
/// <summary> ///// <summary>
/// If set to true then threads and stuff should try to make a graceful exit ///// If set to true then threads and stuff should try to make a graceful exit
/// </summary> ///// </summary>
public bool PleaseShutdown //public bool PleaseShutdown
{ //{
get { return _PleaseShutdown; } // get { return _PleaseShutdown; }
set { _PleaseShutdown = value; } // set { _PleaseShutdown = value; }
} //}
private bool _PleaseShutdown = false; //private bool _PleaseShutdown = false;
} }
} }

View File

@ -27,6 +27,7 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -45,22 +46,22 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <summary> /// <summary>
/// How many ms to sleep if queue is empty /// How many ms to sleep if queue is empty
/// </summary> /// </summary>
private int nothingToDoSleepms;// = 50; private static int nothingToDoSleepms;// = 50;
private ThreadPriority MyThreadPriority; private static ThreadPriority MyThreadPriority;
public long LastExecutionStarted; public long LastExecutionStarted;
public bool InExecution = false; public bool InExecution = false;
public bool KillCurrentScript = false; public bool KillCurrentScript = false;
private EventQueueManager eventQueueManager; //private EventQueueManager eventQueueManager;
public Thread EventQueueThread; public Thread EventQueueThread;
private static int ThreadCount = 0; private static int ThreadCount = 0;
private string ScriptEngineName = "ScriptEngine.Common"; private string ScriptEngineName = "ScriptEngine.Common";
public EventQueueThreadClass(EventQueueManager eqm) public EventQueueThreadClass()//EventQueueManager eqm
{ {
eventQueueManager = eqm; //eventQueueManager = eqm;
ReadConfig(); ReadConfig();
Start(); Start();
} }
@ -72,11 +73,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void ReadConfig() public void ReadConfig()
{ {
ScriptEngineName = eventQueueManager.m_ScriptEngine.ScriptEngineName; lock (ScriptEngine.ScriptEngines)
nothingToDoSleepms = eventQueueManager.m_ScriptEngine.ScriptConfigSource.GetInt("SleepTimeIfNoScriptExecutionMs", 50); {
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
{
ScriptEngineName = m_ScriptEngine.ScriptEngineName;
nothingToDoSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("SleepTimeIfNoScriptExecutionMs", 50);
// Later with ScriptServer we might want to ask OS for stuff too, so doing this a bit manually // Later with ScriptServer we might want to ask OS for stuff too, so doing this a bit manually
string pri = eventQueueManager.m_ScriptEngine.ScriptConfigSource.GetString("ScriptThreadPriority", "BelowNormal"); string pri = m_ScriptEngine.ScriptConfigSource.GetString("ScriptThreadPriority", "BelowNormal");
switch (pri.ToLower()) switch (pri.ToLower())
{ {
case "lowest": case "lowest":
@ -96,10 +101,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
break; break;
default: default:
MyThreadPriority = ThreadPriority.BelowNormal; // Default MyThreadPriority = ThreadPriority.BelowNormal; // Default
eventQueueManager.m_ScriptEngine.Log.Error("[ScriptEngineBase]: Unknown priority type \"" + pri + "\" in config file. Defaulting to \"BelowNormal\"."); m_ScriptEngine.Log.Error("[ScriptEngineBase]: Unknown priority type \"" + pri +
"\" in config file. Defaulting to \"BelowNormal\".");
break; break;
} }
}
}
// Now set that priority // Now set that priority
if (EventQueueThread != null) if (EventQueueThread != null)
if (EventQueueThread.IsAlive) if (EventQueueThread.IsAlive)
@ -127,8 +134,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void Stop() public void Stop()
{ {
PleaseShutdown = true; // Set shutdown flag //PleaseShutdown = true; // Set shutdown flag
Thread.Sleep(100); // Wait a bit //Thread.Sleep(100); // Wait a bit
if (EventQueueThread != null && EventQueueThread.IsAlive == true) if (EventQueueThread != null && EventQueueThread.IsAlive == true)
{ {
try try
@ -143,6 +150,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
} }
private EventQueueManager.QueueItemStruct BlankQIS = new EventQueueManager.QueueItemStruct();
private ScriptEngine lastScriptEngine;
/// <summary> /// <summary>
/// Queue processing thread loop /// Queue processing thread loop
/// </summary> /// </summary>
@ -155,41 +164,71 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{ {
try try
{ {
EventQueueManager.QueueItemStruct BlankQIS = new EventQueueManager.QueueItemStruct();
while (true) while (true)
{ {
DoProcessQueue();
}
}
catch (ThreadAbortException tae)
{
if (lastScriptEngine != null)
lastScriptEngine.Log.Info("[" + ScriptEngineName + "]: ThreadAbortException while executing function.");
}
catch (Exception e)
{
if (lastScriptEngine != null)
lastScriptEngine.Log.Error("[" + ScriptEngineName + "]: Exception in EventQueueThreadLoop: " + e.ToString());
}
}
}
catch (ThreadAbortException)
{
//myScriptEngine.Log.Info("[" + ScriptEngineName + "]: EventQueueManager Worker thread killed: " + tae.Message);
}
}
public void DoProcessQueue()
{
//lock (ScriptEngine.ScriptEngines)
//{
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
{
lastScriptEngine = m_ScriptEngine;
// Every now and then check if we should shut down // Every now and then check if we should shut down
if (PleaseShutdown || eventQueueManager.ThreadsToExit > 0) //if (PleaseShutdown || EventQueueManager.ThreadsToExit > 0)
{ //{
// Someone should shut down, lets get exclusive lock // // Someone should shut down, lets get exclusive lock
lock (eventQueueManager.ThreadsToExitLock) // lock (EventQueueManager.ThreadsToExitLock)
{ // {
// Lets re-check in case someone grabbed it // // Lets re-check in case someone grabbed it
if (eventQueueManager.ThreadsToExit > 0) // if (EventQueueManager.ThreadsToExit > 0)
{ // {
// Its crowded here so we'll shut down // // Its crowded here so we'll shut down
eventQueueManager.ThreadsToExit--; // EventQueueManager.ThreadsToExit--;
Stop(); // Stop();
return; // return;
} // }
else // else
{ // {
// We have been asked to shut down // // We have been asked to shut down
Stop(); // Stop();
return; // return;
} // }
} // }
} //}
//try //try
// { // {
EventQueueManager.QueueItemStruct QIS = BlankQIS; EventQueueManager.QueueItemStruct QIS = BlankQIS;
bool GotItem = false; bool GotItem = false;
if (PleaseShutdown) //if (PleaseShutdown)
return; // return;
if (eventQueueManager.eventQueue.Count == 0) if (m_ScriptEngine.m_EventQueueManager == null || m_ScriptEngine.m_EventQueueManager.eventQueue == null)
continue;
if (m_ScriptEngine.m_EventQueueManager.eventQueue.Count == 0)
{ {
// Nothing to do? Sleep a bit waiting for something to do // Nothing to do? Sleep a bit waiting for something to do
Thread.Sleep(nothingToDoSleepms); Thread.Sleep(nothingToDoSleepms);
@ -200,19 +239,19 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
//myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName); //myScriptEngine.Log.Info("[" + ScriptEngineName + "]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
lock (eventQueueManager.eventQueue) lock (m_ScriptEngine.m_EventQueueManager.eventQueue)
{ {
GotItem = false; GotItem = false;
for (int qc = 0; qc < eventQueueManager.eventQueue.Count; qc++) for (int qc = 0; qc < m_ScriptEngine.m_EventQueueManager.eventQueue.Count; qc++)
{ {
// Get queue item // Get queue item
QIS = eventQueueManager.eventQueue.Dequeue(); QIS = m_ScriptEngine.m_EventQueueManager.eventQueue.Dequeue();
// Check if object is being processed by someone else // Check if object is being processed by someone else
if (eventQueueManager.TryLock(QIS.localID) == false) if (m_ScriptEngine.m_EventQueueManager.TryLock(QIS.localID) == false)
{ {
// Object is already being processed, requeue it // Object is already being processed, requeue it
eventQueueManager.eventQueue.Enqueue(QIS); m_ScriptEngine.m_EventQueueManager.eventQueue.Enqueue(QIS);
} }
else else
{ {
@ -240,7 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
LastExecutionStarted = DateTime.Now.Ticks; LastExecutionStarted = DateTime.Now.Ticks;
KillCurrentScript = false; KillCurrentScript = false;
InExecution = true; InExecution = true;
eventQueueManager.m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID,
QIS.itemID, QIS.itemID,
QIS.functionName, QIS.functionName,
QIS.llDetectParams, QIS.llDetectParams,
@ -272,10 +311,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
if (text.Length > 1500) if (text.Length > 1500)
text = text.Substring(0, 1500); text = text.Substring(0, 1500);
IScriptHost m_host = IScriptHost m_host =
eventQueueManager.m_ScriptEngine.World.GetSceneObjectPart(QIS.localID); m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
//if (m_host != null) //if (m_host != null)
//{ //{
eventQueueManager.m_ScriptEngine.World.SimChat(Helpers.StringToField(text), m_ScriptEngine.World.SimChat(Helpers.StringToField(text),
ChatTypeEnum.Say, 0, ChatTypeEnum.Say, 0,
m_host.AbsolutePosition, m_host.AbsolutePosition,
m_host.Name, m_host.UUID); m_host.Name, m_host.UUID);
@ -286,7 +325,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
//else //else
//{ //{
// T oconsole // T oconsole
eventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName + "]: " + m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName +
"]: " +
"Unable to send text in-world:\r\n" + "Unable to send text in-world:\r\n" +
text); text);
} }
@ -295,7 +335,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// So we are done sending message in-world // So we are done sending message in-world
if (KillCurrentScript) if (KillCurrentScript)
{ {
eventQueueManager.m_ScriptEngine.m_ScriptManager.StopScript( m_ScriptEngine.m_EventQueueManager.m_ScriptEngine.m_ScriptManager.StopScript(
QIS.localID, QIS.itemID); QIS.localID, QIS.itemID);
} }
} }
@ -303,36 +343,22 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
finally finally
{ {
InExecution = false; InExecution = false;
eventQueueManager.ReleaseLock(QIS.localID); m_ScriptEngine.m_EventQueueManager.ReleaseLock(QIS.localID);
} }
} }
} }
} }
} // }
catch (ThreadAbortException tae)
{
eventQueueManager.m_ScriptEngine.Log.Info("[" + ScriptEngineName + "]: ThreadAbortException while executing function.");
}
catch (Exception e)
{
eventQueueManager.m_ScriptEngine.Log.Error("[" + ScriptEngineName + "]: Exception in EventQueueThreadLoop: " + e.ToString());
}
}
}
catch (ThreadAbortException)
{
//myScriptEngine.Log.Info("[" + ScriptEngineName + "]: EventQueueManager Worker thread killed: " + tae.Message);
}
} }
/// <summary> ///// <summary>
/// If set to true then threads and stuff should try to make a graceful exit ///// If set to true then threads and stuff should try to make a graceful exit
/// </summary> ///// </summary>
public bool PleaseShutdown //public bool PleaseShutdown
{ //{
get { return _PleaseShutdown; } // get { return _PleaseShutdown; }
set { _PleaseShutdown = value; } // set { _PleaseShutdown = value; }
} //}
private bool _PleaseShutdown = false; //private bool _PleaseShutdown = false;
} }
} }

View File

@ -27,6 +27,7 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -38,12 +39,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// </summary> /// </summary>
public class MaintenanceThread : iScriptEngineFunctionModule public class MaintenanceThread : iScriptEngineFunctionModule
{ {
public ScriptEngine m_ScriptEngine; //public ScriptEngine m_ScriptEngine;
private int MaintenanceLoopms; private int MaintenanceLoopms;
private int MaintenanceLoopTicks_ScriptLoadUnload;
private int MaintenanceLoopTicks_Other;
public MaintenanceThread(ScriptEngine _ScriptEngine)
public MaintenanceThread()
{ {
m_ScriptEngine = _ScriptEngine; //m_ScriptEngine = _ScriptEngine;
ReadConfig(); ReadConfig();
@ -57,8 +61,21 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
public void ReadConfig() public void ReadConfig()
{
// Bad hack, but we need a m_ScriptEngine :)
lock (ScriptEngine.ScriptEngines)
{
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
{ {
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50); MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
MaintenanceLoopTicks_ScriptLoadUnload =
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
MaintenanceLoopTicks_Other =
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
return;
}
}
} }
#region " Maintenance thread " #region " Maintenance thread "
@ -90,7 +107,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
#if DEBUG #if DEBUG
//m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called"); //m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called");
#endif #endif
PleaseShutdown = true; //PleaseShutdown = true;
Thread.Sleep(100); Thread.Sleep(100);
try try
{ {
@ -105,17 +122,23 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
} }
private ScriptEngine lastScriptEngine; // Keep track of what ScriptEngine instance we are at so we can give exception
/// <summary> /// <summary>
/// A thread should run in this loop and check all running scripts /// A thread should run in this loop and check all running scripts
/// </summary> /// </summary>
public void MaintenanceLoop() public void MaintenanceLoop()
{ {
if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms) //if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
m_ScriptEngine.Log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " + // m_ScriptEngine.Log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
"Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run."); // "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks; long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
long Last_ReReadConfigFilens = DateTime.Now.Ticks; long Last_ReReadConfigFilens = DateTime.Now.Ticks;
int MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
int MaintenanceLoopTicks_Other_Count = 0;
bool MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = false;
bool MaintenanceLoopTicks_Other_ResetCount = false;
while (true) while (true)
{ {
try try
@ -123,34 +146,56 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
while (true) while (true)
{ {
System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
if (PleaseShutdown)
return;
if (m_ScriptEngine != null) // Reset counters?
if (MaintenanceLoopTicks_ScriptLoadUnload_ResetCount)
{ {
MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = false;
MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
}
if (MaintenanceLoopTicks_Other_ResetCount)
{
MaintenanceLoopTicks_Other_ResetCount = false;
MaintenanceLoopTicks_Other_Count = 0;
}
// Increase our counters
MaintenanceLoopTicks_ScriptLoadUnload_Count++;
MaintenanceLoopTicks_Other_Count++;
//lock (ScriptEngine.ScriptEngines)
//{
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
{
lastScriptEngine = m_ScriptEngine;
// Re-reading config every x seconds // Re-reading config every x seconds
if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
{
MaintenanceLoopTicks_Other_ResetCount = true;
if (m_ScriptEngine.RefreshConfigFilens > 0) if (m_ScriptEngine.RefreshConfigFilens > 0)
{ {
// Check if its time to re-read config // Check if its time to re-read config
if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens) if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
m_ScriptEngine.RefreshConfigFilens)
{ {
//Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens ); //Console.WriteLine("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens );
// Its time to re-read config file // Its time to re-read config file
m_ScriptEngine.ReadConfig(); m_ScriptEngine.ReadConfig();
Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
} }
}
// Adjust number of running script threads if not correct // Adjust number of running script threads if not correct
if (m_ScriptEngine.m_EventQueueManager != null) if (m_ScriptEngine.m_EventQueueManager != null)
m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
// Check if any script has exceeded its max execution time // Check if any script has exceeded its max execution time
if (m_ScriptEngine.m_EventQueueManager != null && m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) if (EventQueueManager.EnforceMaxExecutionTime)
{ {
// We are enforcing execution time // We are enforcing execution time
if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens) EventQueueManager.maxFunctionExecutionTimens)
{ {
// Its time to check again // Its time to check again
m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
@ -159,24 +204,35 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
} }
} }
if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
{
MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
// LOAD / UNLOAD SCRIPTS
if (m_ScriptEngine.m_ScriptManager != null)
m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
}
}
//}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: " + ex.ToString()); if (lastScriptEngine != null)
lastScriptEngine.Log.Error("[" + lastScriptEngine.ScriptEngineName + "]: Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: " + ex.ToString());
Thread.Sleep(5000); Thread.Sleep(5000);
} }
} }
} }
#endregion #endregion
/// <summary> ///// <summary>
/// If set to true then threads and stuff should try to make a graceful exit ///// If set to true then threads and stuff should try to make a graceful exit
/// </summary> ///// </summary>
public bool PleaseShutdown //public bool PleaseShutdown
{ //{
get { return _PleaseShutdown; } // get { return _PleaseShutdown; }
set { _PleaseShutdown = value; } // set { _PleaseShutdown = value; }
} //}
private bool _PleaseShutdown = false; //private bool _PleaseShutdown = false;
} }
} }

View File

@ -27,6 +27,7 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using Nini.Config; using Nini.Config;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
@ -44,15 +45,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
[Serializable] [Serializable]
public abstract class ScriptEngine : IRegionModule, OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.ScriptEngine, iScriptEngineFunctionModule public abstract class ScriptEngine : IRegionModule, OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.ScriptEngine, iScriptEngineFunctionModule
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static List<ScriptEngine> ScriptEngines = new List<ScriptEngine>();
public Scene World; public Scene World;
public EventManager m_EventManager; // Handles and queues incoming events from OpenSim public EventManager m_EventManager; // Handles and queues incoming events from OpenSim
public EventQueueManager m_EventQueueManager; // Executes events, handles script threads public EventQueueManager m_EventQueueManager; // Executes events, handles script threads
public ScriptManager m_ScriptManager; // Load, unload and execute scripts public ScriptManager m_ScriptManager; // Load, unload and execute scripts
public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains
public AsyncLSLCommandManager m_ASYNCLSLCommandManager; // Asyncronous LSL commands (commands that returns with an event) public AsyncLSLCommandManager m_ASYNCLSLCommandManager; // Asyncronous LSL commands (commands that returns with an event)
public MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long public static MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long
public IConfigSource ConfigSource; public IConfigSource ConfigSource;
public IConfig ScriptConfigSource; public IConfig ScriptConfigSource;
@ -81,8 +83,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public ScriptEngine() public ScriptEngine()
{ {
//Common.SendToDebug("ScriptEngine Object Initialized"); Common.mySE = this; // For logging, just need any instance, doesn't matter
Common.mySE = this; lock (ScriptEngines)
{
ScriptEngines.Add(this); // Keep a list of ScriptEngines for shared threads to process all instances
}
} }
public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager) public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager)
@ -106,7 +111,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
m_ScriptManager = newScriptManager; m_ScriptManager = newScriptManager;
m_AppDomainManager = new AppDomainManager(this); m_AppDomainManager = new AppDomainManager(this);
m_ASYNCLSLCommandManager = new AsyncLSLCommandManager(this); m_ASYNCLSLCommandManager = new AsyncLSLCommandManager(this);
m_MaintenanceThread = new MaintenanceThread(this); if (m_MaintenanceThread == null)
m_MaintenanceThread = new MaintenanceThread();
m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\""); m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\"");
ReadConfig(); ReadConfig();
@ -118,6 +124,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void Shutdown() public void Shutdown()
{ {
// We are shutting down // We are shutting down
lock (ScriptEngines)
{
ScriptEngines.Remove(this);
}
} }
ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager() ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager()
@ -128,17 +138,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public void ReadConfig() public void ReadConfig()
{ {
#if DEBUG #if DEBUG
m_log.Debug("[" + ScriptEngineName + "]: Refreshing configuration for all modules"); //m_log.Debug("[" + ScriptEngineName + "]: Refreshing configuration for all modules");
#endif #endif
RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30); RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30);
// Reload from disk? No!
//ConfigSource.Reload();
//if (File.Exists(OpenSim.Application.iniFilePath))
//{
// //ConfigSource.Merge(new IniConfigSource(OpenSim.Application.iniFilePath));
//}
// Create a new object (probably not necessary?) // Create a new object (probably not necessary?)
// ScriptConfigSource = ConfigSource.Configs[ScriptEngineName]; // ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
@ -175,15 +178,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
#endregion #endregion
/// <summary>
/// If set to true then threads and stuff should try to make a graceful exit
/// </summary>
public bool PleaseShutdown
{
get { return _PleaseShutdown; }
set { _PleaseShutdown = value; }
}
private bool _PleaseShutdown = false;
} }
} }

View File

@ -129,14 +129,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
if (PrivateThread) if (PrivateThread)
{ {
// Assign one thread per region // Assign one thread per region
scriptLoadUnloadThread = StartScriptLoadUnloadThread(); //scriptLoadUnloadThread = StartScriptLoadUnloadThread();
} }
else else
{ {
// Shared thread - make sure one exist, then assign it to the private // Shared thread - make sure one exist, then assign it to the private
if (staticScriptLoadUnloadThread == null) if (staticScriptLoadUnloadThread == null)
{ {
staticScriptLoadUnloadThread = StartScriptLoadUnloadThread(); //staticScriptLoadUnloadThread = StartScriptLoadUnloadThread();
} }
scriptLoadUnloadThread = staticScriptLoadUnloadThread; scriptLoadUnloadThread = staticScriptLoadUnloadThread;
} }
@ -169,15 +169,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// Abort load/unload thread // Abort load/unload thread
try try
{ {
PleaseShutdown = true; //PleaseShutdown = true;
Thread.Sleep(100); //Thread.Sleep(100);
if (scriptLoadUnloadThread != null) if (scriptLoadUnloadThread != null && scriptLoadUnloadThread.IsAlive == true)
{
if (scriptLoadUnloadThread.IsAlive == true)
{ {
scriptLoadUnloadThread.Abort(); scriptLoadUnloadThread.Abort();
scriptLoadUnloadThread.Join(); //scriptLoadUnloadThread.Join();
}
} }
} }
catch catch
@ -197,8 +194,21 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{ {
if (LUQueue.Count == 0) if (LUQueue.Count == 0)
Thread.Sleep(scriptLoadUnloadThread_IdleSleepms); Thread.Sleep(scriptLoadUnloadThread_IdleSleepms);
if (PleaseShutdown) //if (PleaseShutdown)
return; // return;
DoScriptLoadUnload();
}
}
catch (ThreadAbortException tae)
{
string a = tae.ToString();
a = String.Empty;
// Expected
}
}
public void DoScriptLoadUnload()
{
if (LUQueue.Count > 0) if (LUQueue.Count > 0)
{ {
LUStruct item = LUQueue.Dequeue(); LUStruct item = LUQueue.Dequeue();
@ -214,14 +224,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
} }
} }
} }
}
}
catch (ThreadAbortException tae)
{
string a = tae.ToString();
a = String.Empty;
// Expected
}
} }
#endregion #endregion
@ -418,15 +421,15 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
#endregion #endregion
/// <summary> ///// <summary>
/// If set to true then threads and stuff should try to make a graceful exit ///// If set to true then threads and stuff should try to make a graceful exit
/// </summary> ///// </summary>
public bool PleaseShutdown //public bool PleaseShutdown
{ //{
get { return _PleaseShutdown; } // get { return _PleaseShutdown; }
set { _PleaseShutdown = value; } // set { _PleaseShutdown = value; }
} //}
private bool _PleaseShutdown = false; //private bool _PleaseShutdown = false;
} }
} }

View File

@ -35,6 +35,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public interface iScriptEngineFunctionModule public interface iScriptEngineFunctionModule
{ {
void ReadConfig(); void ReadConfig();
bool PleaseShutdown { get; set; } // bool PleaseShutdown { get; set; }
} }
} }

View File

@ -171,8 +171,8 @@ msgformat = "PRIVMSG {0} : {3} - {1} of {2}"
; Refresh ScriptEngine config options (these settings) every xx seconds ; Refresh ScriptEngine config options (these settings) every xx seconds
; 0 = Do not refresh ; 0 = Do not refresh
; Set it to number of seconds between refresh, for example 30. ; Set it to number of seconds between refresh, for example 30.
; Will allow you to change ScriptEngine settings while server is running just by editing this file. ; Will allow you to change ScriptEngine settings while server is running just by using "CONFIG SET" on console
; For example to increase or decrease number of threads. ; For example to increase or decrease number of threads: CONFIG SET NumberOfScriptThreads 10
; NOTE! Disabled for now. Feature does not work. ; NOTE! Disabled for now. Feature does not work.
RefreshConfig=0 RefreshConfig=0
@ -184,14 +184,6 @@ NumberOfScriptThreads=2
; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest ; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest
ScriptThreadPriority=BelowNormal ScriptThreadPriority=BelowNormal
; Should the script threads be private for each region?
; true: Each region will get <NumberOfScriptThreads> dedicated to scripts within that region
; Number of threads will be <NumberOfScriptThreads>*<NumberOfRegions>
; false: All regions share <NumberOfScriptThreads> for all their scripts
; Note! If you run multiple script engines based on "OpenSim.Region.ScriptEngine.Common" then all of them will share the same threads.
; *** This setting will not work until you restart OpenSim
PrivateRegionThreads=false
; How long MAX should a script event be allowed to run (per event execution)? ; How long MAX should a script event be allowed to run (per event execution)?
; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function ; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function
; There is also a small speed penalty for every kill that is made ; There is also a small speed penalty for every kill that is made
@ -218,15 +210,24 @@ SleepTimeIfNoScriptExecutionMs=50
; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead. ; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead.
ScriptsPerAppDomain=1 ScriptsPerAppDomain=1
; Script loading / unloading sleep ; MaintenanceLoop
; How often to run maintenance loop
; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
MaintenanceLoopms=50
; How many maintenanceloops between each of these.
; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
; Script loading/unloading
; How long load/unload thread should sleep if there is nothing to do ; How long load/unload thread should sleep if there is nothing to do
; Higher value makes it respond slower when scripts are added/removed from prims ; Higher value makes it respond slower when scripts are added/removed from prims
; But once active it will process all in queue before sleeping again ; But once active it will process all in queue before sleeping again
ScriptLoadUnloadLoopms=30 MaintenanceLoopTicks_ScriptLoadUnload=1
; Other tasks
; check if we need to reload config, adjust running config and enforce max execution time
MaintenanceLoopTicks_Other=10
; Loading and unloading of scripts is queued and processed by a separate thread.
; This thread can either be shared among all regions, or private (one thread per region)
PrivateScriptLoadUnloadThread=false
; Maximum number of items in load/unload queue before we start rejecting loads ; Maximum number of items in load/unload queue before we start rejecting loads
; Note that we will only be rejecting load. Unloads will still be able to queue. ; Note that we will only be rejecting load. Unloads will still be able to queue.

View File

@ -1,41 +1 @@
STARTUP COMPLETE
### ###
####### #### #######
############################
############################
###########################
#########################
#####################
###### ###### #######
##### #### ######
##### #### ######
###### ###### #######
######################
#######################
#########################
###########################
###########################
###########################
###########################
##########################
#########################
#######################
#####################
##################
#############
### ##### ### ## ### ###
####### ###### ## ### ###
### ## ## ## ## #### ####
## ### ## ### ### ## ### ## ## #### ####
### ## ####### ##### ###### #### ## #### ####
### ## ## ## ## # ## ## ###### ## ## # # ##
### ## ## ## ####### ## ## ### ## ## ### ##
## ### ## ## ## ## ## ## ## ## ## ### ##
### ### ### ## ## ## ## ## ### ### ## ## ### ##
####### ###### ##### ## ## ###### ## ## # ##
### ## ## ### ###
##
## STARTUP COMPLETE
http://opensimulator.org/wiki/FAQ

View File

@ -147,6 +147,7 @@
<ReferencePath>../../../bin/</ReferencePath> <ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/> <Reference name="System"/>
<Reference name="libsecondlife.dll"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Files> <Files>
@ -380,6 +381,7 @@
<Reference name="Axiom.MathLib.dll" localCopy="false"/> <Reference name="Axiom.MathLib.dll" localCopy="false"/>
<Reference name="OpenSim.Framework" localCopy="false"/> <Reference name="OpenSim.Framework" localCopy="false"/>
<Reference name="OpenSim.Framework.Console" localCopy="false"/> <Reference name="OpenSim.Framework.Console" localCopy="false"/>
<Reference name="nunit.framework.dll" />
<Reference name="Nini.dll" /> <Reference name="Nini.dll" />
<Reference name="log4net"/> <Reference name="log4net"/>
@ -478,6 +480,7 @@
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Region.Physics.Manager" localCopy="false"/> <Reference name="OpenSim.Region.Physics.Manager" localCopy="false"/>
<Reference name="Ode.NET.dll" localCopy="false" /> <Reference name="Ode.NET.dll" localCopy="false" />
<Reference name="nunit.framework.dll" />
<Reference name="log4net"/> <Reference name="log4net"/>
<Files> <Files>
@ -752,6 +755,7 @@
<Reference name="OpenSim.Framework.Servers"/> <Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Communications"/> <Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Statistics"/>
<Reference name="OpenSim.Region.Communications.Local"/> <Reference name="OpenSim.Region.Communications.Local"/>
<Reference name="OpenSim.Region.Physics.Manager"/> <Reference name="OpenSim.Region.Physics.Manager"/>
<Reference name="XMLRPC.dll"/> <Reference name="XMLRPC.dll"/>
@ -1506,36 +1510,6 @@
</Files> </Files>
</Project> </Project>
<Project name="LaunchSLClient" path="OpenSim/Tools/LaunchSLClient" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System" localCopy="false"/>
<Reference name="System.IO" localCopy="false"/>
<Reference name="System.Collections" localCopy="false"/>
<Reference name="System.Collections.Generic" localCopy="false"/>
<Reference name="System.ComponentModel" localCopy="false"/>
<Reference name="System.Data" localCopy="false"/>
<Reference name="System.Diagnostics" localCopy="false"/>
<Reference name="System.Drawing" localCopy="false"/>
<Reference name="System.Text" localCopy="false"/>
<Reference name="System.Text.RegularExpressions" localCopy="false"/>
<Reference name="System.Windows.Forms" localCopy="false"/>
<Reference name="Microsoft.Win32" localCopy="false"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
</Solution> </Solution>
<!-- Prebuild tool --> <!-- Prebuild tool -->