diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index a9432c2df3..2c38e0f6a1 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -66,6 +66,11 @@ namespace OpenSim.Framework
IConfigSource Config { get; }
+ ///
+ /// Are logins enabled on this simulator?
+ ///
+ bool LoginsEnabled { get; set; }
+
float TimeDilation { get; }
bool AllowScriptCrossings { get; }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 394b90a691..c679a7bfc6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -636,10 +636,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.InventoryService.UpdateItem(item);
- // this gets called when the agent logs off!
+ // If the name of the object has been changed whilst attached then we want to update the inventory
+ // item in the viewer.
if (sp.ControllingClient != null)
sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
}
+
grp.HasGroupChanged = false; // Prevent it being saved over and over
}
// else
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 6064ddc426..1406aaec25 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -141,13 +141,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
foreach (Scene scene in m_Scenes)
{
// m_log.DebugFormat(
-// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
+// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
// toAgentID.ToString(), scene.RegionInfo.RegionName);
+
ScenePresence sp = scene.GetScenePresence(toAgentID);
if (sp != null && !sp.IsChildAgent)
{
// Local message
-// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID);
+ m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID);
+
sp.ControllingClient.SendInstantMessage(im);
// Message sent
@@ -159,13 +161,15 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// try child avatar second
foreach (Scene scene in m_Scenes)
{
-// m_log.DebugFormat(
-// "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
+ m_log.DebugFormat(
+ "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
+
ScenePresence sp = scene.GetScenePresence(toAgentID);
if (sp != null)
{
// Local message
-// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID);
+ m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", sp.Name, toAgentID);
+
sp.ControllingClient.SendInstantMessage(im);
// Message sent
@@ -174,10 +178,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
}
}
-// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID);
- SendGridInstantMessageViaXMLRPC(im, result);
+ m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID);
- return;
+ SendGridInstantMessageViaXMLRPC(im, result);
}
private void HandleUndeliveredMessage(GridInstantMessage im, MessageResultNotification result)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 80554fb3aa..81de29c108 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -313,8 +313,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
}
}
- else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined ||
- im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined)
+ else if (
+ im.dialog == (byte)InstantMessageDialog.InventoryDeclined
+ || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined)
{
// Here, the recipient is local and we can assume that the
// inventory is loaded. Courtesy of the above bulk update,
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index 6cd077a47a..7ed13206f0 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -149,10 +149,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
lock (m_scenes)
m_scenes[scene.RegionInfo.RegionID] = scene;
- scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
+ scene.EventManager.OnRegionReady += s => UploadMapTile(s);
}
-
///
///
///
@@ -166,21 +165,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
}
#endregion ISharedRegionModule
-
- void OnLoginsEnabled(string regionName)
- {
- Scene scene = null;
- foreach (Scene s in m_scenes.Values)
- if (s.RegionInfo.RegionName == regionName)
- {
- scene = s;
- break;
- }
- if (scene != null)
- UploadMapTile(scene);
- }
-
-
+
///
///
///
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
index 553a32d3bd..e7b14547f4 100644
--- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
+++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs
@@ -129,18 +129,18 @@ namespace OpenSim.Region.CoreModules.World
switch (cmd[1])
{
case "enable":
- scene.LoginsDisabled = false;
+ scene.LoginsEnabled = true;
MainConsole.Instance.Output(String.Format("Logins are enabled for region {0}", scene.RegionInfo.RegionName));
break;
case "disable":
- scene.LoginsDisabled = true;
+ scene.LoginsEnabled = false;
MainConsole.Instance.Output(String.Format("Logins are disabled for region {0}", scene.RegionInfo.RegionName));
break;
case "status":
- if (scene.LoginsDisabled)
- MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
- else
+ if (scene.LoginsEnabled)
MainConsole.Instance.Output(String.Format("Login in {0} are enabled", scene.RegionInfo.RegionName));
+ else
+ MainConsole.Instance.Output(String.Format("Login in {0} are disabled", scene.RegionInfo.RegionName));
break;
default:
MainConsole.Instance.Output("Syntax: login enable|disable|status");
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
index aa4a757420..136ca9261b 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs
@@ -25,14 +25,23 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
using System;
+using OpenSim.Framework;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IRegionReadyModule
{
void OarLoadingAlert(string msg);
+
+ ///
+ /// Trigger region ready status manually.
+ ///
+ ///
+ /// This should be called by the scene if the IRegionReadyModule has set Scene.LoginLock == true
+ ///
+ ///
+ void TriggerRegionReady(IScene scene);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index d783e57620..418904f65d 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -500,15 +500,25 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void RegionHeartbeatEnd(Scene scene);
public event RegionHeartbeatEnd OnRegionHeartbeatEnd;
- public delegate void LoginsEnabled(string regionName);
-
///
- /// This should only fire in all circumstances if the RegionReady module is active.
+ /// Fired when logins to a region are enabled or disabled.
///
///
- /// TODO: Fire this even when the RegionReady module is not active.
+ ///
///
- public event LoginsEnabled OnLoginsEnabled;
+ /// Fired
+ public event RegionLoginsStatusChange OnRegionLoginsStatusChange;
+ public delegate void RegionLoginsStatusChange(IScene scene);
+
+ ///
+ /// Fired when a region is considered ready for use.
+ ///
+ ///
+ /// A region is considered ready when startup operations such as loading of scripts already on the region
+ /// have been completed.
+ ///
+ public event RegionReady OnRegionReady;
+ public delegate void RegionReady(IScene scene);
public delegate void PrimsLoaded(Scene s);
public event PrimsLoaded OnPrimsLoaded;
@@ -2502,21 +2512,42 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public void TriggerLoginsEnabled (string regionName)
+ public void TriggerRegionLoginsStatusChange(IScene scene)
{
- LoginsEnabled handler = OnLoginsEnabled;
+ RegionLoginsStatusChange handler = OnRegionLoginsStatusChange;
- if ( handler != null)
+ if (handler != null)
{
- foreach (LoginsEnabled d in handler.GetInvocationList())
+ foreach (RegionLoginsStatusChange d in handler.GetInvocationList())
{
try
{
- d(regionName);
+ d(scene);
}
catch (Exception e)
{
- m_log.ErrorFormat("[EVENT MANAGER]: Delegate for LoginsEnabled failed - continuing {0} - {1}",
+ m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionLoginsStatusChange failed - continuing {0} - {1}",
+ e.Message, e.StackTrace);
+ }
+ }
+ }
+ }
+
+ public void TriggerRegionReady(IScene scene)
+ {
+ RegionReady handler = OnRegionReady;
+
+ if (handler != null)
+ {
+ foreach (RegionReady d in handler.GetInvocationList())
+ {
+ try
+ {
+ d(scene);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReady failed - continuing {0} - {1}",
e.Message, e.StackTrace);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f5018283c7..645b3d528c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -129,9 +129,10 @@ namespace OpenSim.Region.Framework.Scenes
public bool m_strictAccessControl = true;
public bool m_seeIntoBannedRegion = false;
public int MaxUndoCount = 5;
+
// Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
public bool LoginLock = false;
- public bool LoginsDisabled = true;
+
public bool StartDisabled = false;
public bool LoadingPrims;
public IXfer XferManager;
@@ -727,6 +728,8 @@ namespace OpenSim.Region.Framework.Scenes
{
IConfig startupConfig = m_config.Configs["Startup"];
+ StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
+
m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup);
if (!m_useBackup)
@@ -1530,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes
// landMS = Util.EnvironmentTickCountSubtract(ldMS);
//}
- if (LoginsDisabled && Frame == 20)
+ if (!LoginsEnabled && Frame == 20)
{
// m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock);
@@ -1538,31 +1541,34 @@ namespace OpenSim.Region.Framework.Scenes
// this is a rare case where we know we have just went through a long cycle of heap
// allocations, and there is no more work to be done until someone logs in
GC.Collect();
-
- IConfig startupConfig = m_config.Configs["Startup"];
- if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false))
+
+ if (!LoginLock)
+ {
+ if (!StartDisabled)
+ {
+ m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
+ LoginsEnabled = true;
+ }
+
+ m_sceneGridService.InformNeighborsThatRegionisUp(
+ RequestModuleInterface(), RegionInfo);
+
+ // Region ready should always be triggered whether logins are immediately enabled or not.
+ EventManager.TriggerRegionReady(this);
+ }
+ else
{
// This handles a case of a region having no scripts for the RegionReady module
if (m_sceneGraph.GetActiveScriptsCount() == 0)
{
- // need to be able to tell these have changed in RegionReady
- LoginLock = false;
- EventManager.TriggerLoginsEnabled(RegionInfo.RegionName);
+ // In this case, we leave it to the IRegionReadyModule to enable logins
+
+ // LoginLock can currently only be set by a region module implementation.
+ // If somehow this hasn't been done then the quickest way to bugfix is to see the
+ // NullReferenceException
+ IRegionReadyModule rrm = RequestModuleInterface();
+ rrm.TriggerRegionReady(this);
}
-
- // For RegionReady lockouts
- if (!LoginLock)
- {
- m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
- LoginsDisabled = false;
- }
-
- m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo);
- }
- else
- {
- StartDisabled = true;
- LoginsDisabled = true;
}
}
}
@@ -3487,25 +3493,31 @@ namespace OpenSim.Region.Framework.Scenes
if (AgentTransactionsModule != null)
AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
- avatar.Close();
-
m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
m_log.Debug("[Scene] The avatar has left the building");
}
catch (Exception e)
{
m_log.Error(
- string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e);
+ string.Format("[SCENE]: Exception removing {0} from {1}. Cleaning up. Exception ", avatar.Name, Name), e);
}
finally
{
- // Always clean these structures up so that any failure above doesn't cause them to remain in the
- // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
- // the same cleanup exception continually.
- // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
- // since this would hide the underlying failure and other associated problems.
- m_sceneGraph.RemoveScenePresence(agentID);
- m_clientManager.Remove(agentID);
+ try
+ {
+ // Always clean these structures up so that any failure above doesn't cause them to remain in the
+ // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
+ // the same cleanup exception continually.
+ m_sceneGraph.RemoveScenePresence(agentID);
+ m_clientManager.Remove(agentID);
+
+ avatar.Close();
+ }
+ catch (Exception e)
+ {
+ m_log.Error(
+ string.Format("[SCENE]: Exception in final clean up of {0} in {1}. Exception ", avatar.Name, Name), e);
+ }
}
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3619,7 +3631,7 @@ namespace OpenSim.Region.Framework.Scenes
agent.startpos
);
- if (LoginsDisabled)
+ if (!LoginsEnabled)
{
reason = "Logins Disabled";
return false;
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 8db439720c..d55b08240d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -106,6 +106,24 @@ namespace OpenSim.Region.Framework.Scenes
protected readonly ClientManager m_clientManager = new ClientManager();
+ public bool LoginsEnabled
+ {
+ get
+ {
+ return m_loginsEnabled;
+ }
+
+ set
+ {
+ if (m_loginsEnabled != value)
+ {
+ m_loginsEnabled = value;
+ EventManager.TriggerRegionLoginsStatusChange(this);
+ }
+ }
+ }
+ private bool m_loginsEnabled;
+
public float TimeDilation
{
get { return 1.0f; }
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5d8447bddb..775a4c2c5d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.WarnFormat(
"[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
- x / Constants.RegionSize, y / Constants.RegionSize);
+ m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 6ab0027d7e..08c7a58519 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1991,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes
try
{
if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart
- m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things
+ !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things
m_scene.LoadingPrims) // Land may not be valid yet
{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index a407f01d63..37b5184715 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -301,7 +301,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
sp.AbsolutePosition = preTeleportPosition;
// Make sceneB refuse CreateAgent
- sceneB.LoginsDisabled = true;
+ sceneB.LoginsEnabled = false;
sceneA.RequestTeleportLocation(
sp.ControllingClient,
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index 600cafb7c4..e49ad2a3f8 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -31,16 +31,14 @@ using System.Reflection;
using System.Net;
using System.IO;
using System.Text;
-
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
-using OpenSim.Services.Interfaces;
-
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{
@@ -56,10 +54,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
private bool m_lastOarLoadedOk;
private int m_channelNotify = -1000;
private bool m_enabled = false;
- private bool m_disable_logins = false;
+ private bool m_disable_logins;
private string m_uri = string.Empty;
- Scene m_scene = null;
+ Scene m_scene;
#region INonSharedRegionModule interface
@@ -99,47 +97,35 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
m_lastOarLoadedOk = true;
m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
- m_scene.EventManager.OnRezScript += OnRezScript;
- m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
- if (m_disable_logins == true)
+ if (m_disable_logins)
{
- scene.LoginLock = true;
- scene.LoginsDisabled = true;
- m_log.InfoFormat("[RegionReady]: Region {0} - logins disabled during initialization.",m_scene.RegionInfo.RegionName);
+ m_scene.LoginLock = true;
+ m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
- if(m_uri != string.Empty)
+ m_log.InfoFormat("[RegionReady]: Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name);
+
+ if (m_uri != string.Empty)
{
RRAlert("disabled");
}
}
}
- void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
- {
- if (!m_ScriptRez)
- {
- m_ScriptRez = true;
- m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
- m_scene.EventManager.OnRezScript -= OnRezScript;
- }
- }
-
public void RemoveRegion(Scene scene)
{
if (!m_enabled)
return;
- m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
- m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled;
- if(m_uri != string.Empty)
- {
+ if (m_disable_logins)
+ m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
+
+ if (m_uri != string.Empty)
RRAlert("shutdown");
- }
m_scene = null;
}
@@ -159,7 +145,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
#endregion
-
void OnEmptyScriptCompileQueue(int numScriptsFailed, string message)
{
m_log.DebugFormat("[RegionReady]: Script compile queue empty!");
@@ -193,75 +178,80 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
m_scene.RegionInfo.RegionName, c.Message, m_channelNotify);
m_scene.EventManager.TriggerOnChatBroadcast(this, c);
- m_scene.EventManager.TriggerLoginsEnabled(m_scene.RegionInfo.RegionName);
- m_scene.SceneGridService.InformNeighborsThatRegionisUp(m_scene.RequestModuleInterface(), m_scene.RegionInfo);
+
+ TriggerRegionReady(m_scene);
}
}
void OnOarFileLoaded(Guid requestId, string message)
{
m_oarFileLoading = true;
+
if (message==String.Empty)
{
m_lastOarLoadedOk = true;
- } else {
+ }
+ else
+ {
m_log.WarnFormat("[RegionReady]: Oar file load errors: {0}", message);
m_lastOarLoadedOk = false;
}
}
- // This will be triggerd by Scene if we have no scripts
- // m_ScriptsRezzing will be false if there were none
- // else it will be true and we should wait on the
- // empty compile queue
- void OnLoginsEnabled(string regionName)
+ ///
+ /// This will be triggered by Scene directly if it contains no scripts on startup. Otherwise it is triggered
+ /// when the script compile queue is empty after initial region startup.
+ ///
+ ///
+ public void TriggerRegionReady(IScene scene)
{
- if (m_disable_logins == true)
+ m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
+ m_scene.LoginLock = false;
+
+ if (!m_scene.StartDisabled)
{
- if (m_scene.StartDisabled == false)
- {
- m_scene.LoginsDisabled = false;
- m_scene.LoginLock = false;
+ m_scene.LoginsEnabled = true;
- m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
+ // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
+ // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
- // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
- // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
-
- m_log.InfoFormat(
- "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name);
-
- if (m_uri != string.Empty)
- {
- RRAlert("enabled");
- }
- }
+ m_log.InfoFormat(
+ "[RegionReady]: INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name);
}
+
+ m_scene.SceneGridService.InformNeighborsThatRegionisUp(
+ m_scene.RequestModuleInterface(), m_scene.RegionInfo);
+
+ if (m_uri != string.Empty)
+ {
+ RRAlert("enabled");
+ }
+
+ m_scene.EventManager.TriggerRegionReady(m_scene);
}
public void OarLoadingAlert(string msg)
{
// Let's bypass this for now until some better feedback can be established
//
- return;
- if (msg == "load")
- {
- m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
- m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
- m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
- m_scene.EventManager.OnRezScript += OnRezScript;
- m_oarFileLoading = true;
- m_firstEmptyCompileQueue = true;
-
- m_scene.LoginsDisabled = true;
- m_scene.LoginLock = true;
- if ( m_uri != string.Empty )
- {
- RRAlert("loading oar");
- RRAlert("disabled");
- }
- }
+// if (msg == "load")
+// {
+// m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
+// m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
+// m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
+// m_scene.EventManager.OnRezScript += OnRezScript;
+// m_oarFileLoading = true;
+// m_firstEmptyCompileQueue = true;
+//
+// m_scene.LoginsDisabled = true;
+// m_scene.LoginLock = true;
+// if ( m_uri != string.Empty )
+// {
+// RRAlert("loading oar");
+// RRAlert("disabled");
+// }
+// }
}
public void RRAlert(string status)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7cb4a26db5..6dfd7234c9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6887,22 +6887,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (folderID == UUID.Zero)
return;
- byte[] bucket = new byte[1];
- bucket[0] = (byte)AssetType.Folder;
- //byte[] objBytes = folderID.GetBytes();
- //Array.Copy(objBytes, 0, bucket, 1, 16);
-
- GridInstantMessage msg = new GridInstantMessage(World,
- m_host.OwnerID, m_host.Name, destID,
- (byte)InstantMessageDialog.TaskInventoryOffered,
- false, category+". "+m_host.Name+" is located at "+
- World.RegionInfo.RegionName+" "+
- m_host.AbsolutePosition.ToString(),
- folderID, true, m_host.AbsolutePosition,
- bucket);
-
if (m_TransferModule != null)
+ {
+ byte[] bucket = new byte[] { (byte)AssetType.Folder };
+
+ GridInstantMessage msg = new GridInstantMessage(World,
+ m_host.UUID, m_host.Name + ", an object owned by " +
+ resolveName(m_host.OwnerID) + ",", destID,
+ (byte)InstantMessageDialog.TaskInventoryOffered,
+ false, category + "\n" + m_host.Name + " is located at " +
+ World.RegionInfo.RegionName + " " +
+ m_host.AbsolutePosition.ToString(),
+ folderID, true, m_host.AbsolutePosition,
+ bucket);
+
m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
+ }
}
public void llSetVehicleType(int type)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 983eed2a03..771db0c238 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -312,11 +312,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
part.SetScriptEvents(ItemID,
(int)m_Script.GetStateEventFlags(State));
- Running = false;
-
- if (ShuttingDown)
+ if (!Running)
m_startOnInit = false;
+ Running = false;
+
// we get new rez events on sim restart, too
// but if there is state, then we fire the change
// event
@@ -352,12 +352,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public void Init()
{
- if (!m_startOnInit)
+ if (ShuttingDown)
return;
if (m_startedFromSavedState)
{
- Start();
+ if (m_startOnInit)
+ Start();
if (m_postOnRez)
{
PostEvent(new EventParams("on_rez",
@@ -389,7 +390,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
else
{
- Start();
+ if (m_startOnInit)
+ Start();
PostEvent(new EventParams("state_entry",
new Object[0], new DetectParams[0]));
if (m_postOnRez)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 35a0200f0f..79a6e0951e 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -109,6 +109,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private bool m_KillTimedOutScripts;
private string m_ScriptEnginesPath = null;
+ private ExpiringCache m_runFlags = new ExpiringCache();
+
///
/// Is the entire simulator in the process of shutting down?
///
@@ -715,6 +717,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
m_Scene.EventManager.OnShutdown += OnShutdown;
+ // If region ready has been triggered, then the region had no scripts to compile and completed its other
+ // work.
+ m_Scene.EventManager.OnRegionReady += s => m_InitialStartup = false;
+
if (m_SleepTime > 0)
{
m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
@@ -1269,7 +1275,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (instance!=null)
instance.Init();
-
+
+ bool runIt;
+ if (m_runFlags.TryGetValue(itemID, out runIt))
+ {
+ if (!runIt)
+ StopScript(itemID);
+ m_runFlags.Remove(itemID);
+ }
+
return true;
}
@@ -1660,6 +1674,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
IScriptInstance instance = GetInstance(itemID);
if (instance != null)
instance.Start();
+ else
+ m_runFlags.AddOrUpdate(itemID, true, 240);
}
public void StopScript(UUID itemID)
@@ -1671,6 +1687,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort.
instance.Stop(1000);
}
+ else
+ {
+ m_runFlags.AddOrUpdate(itemID, false, 240);
+ }
}
public DetectParams GetDetectParams(UUID itemID, int idx)
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 769de83c9c..7598cc360e 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -190,7 +190,7 @@ namespace OpenSim.Tests.Common
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
testScene.RegionInfo.EstateSettings = new EstateSettings();
- testScene.LoginsDisabled = false;
+ testScene.LoginsEnabled = true;
testScene.RegisterRegionWithGrid();
SceneManager.Add(testScene);