On startup, start scenes after we're set up all local scenes, rather than starting scenes before others have been created.

This aims to avoid a race condition where scenes could look to inform neighbours that they were up before those neighbours had been created.
http://opensimulator.org/mantis/view.php?id=6618
user_profiles
Justin Clark-Casey (justincc) 2013-05-03 18:48:50 +01:00
parent 386d67ec61
commit 304c5d4a8b
6 changed files with 41 additions and 14 deletions

View File

@ -115,6 +115,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
Environment.Exit(1); Environment.Exit(1);
} }
List<IScene> createdScenes = new List<IScene>();
for (int i = 0; i < regionsToLoad.Length; i++) for (int i = 0; i < regionsToLoad.Length; i++)
{ {
IScene scene; IScene scene;
@ -123,17 +125,22 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
")"); ")");
bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]);
m_openSim.CreateRegion(regionsToLoad[i], true, out scene); m_openSim.CreateRegion(regionsToLoad[i], true, out scene);
createdScenes.Add(scene);
if (changed) if (changed)
regionsToLoad[i].EstateSettings.Save(); regionsToLoad[i].EstateSettings.Save();
}
if (scene != null)
foreach (IScene scene in createdScenes)
{
scene.Start();
m_newRegionCreatedHandler = OnNewRegionCreated;
if (m_newRegionCreatedHandler != null)
{ {
m_newRegionCreatedHandler = OnNewRegionCreated; m_newRegionCreatedHandler(scene);
if (m_newRegionCreatedHandler != null)
{
m_newRegionCreatedHandler(scene);
}
} }
} }
} }

View File

@ -700,6 +700,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
IScene newScene; IScene newScene;
m_application.CreateRegion(region, out newScene); m_application.CreateRegion(region, out newScene);
newScene.Start();
// If an access specification was provided, use it. // If an access specification was provided, use it.
// Otherwise accept the default. // Otherwise accept the default.

View File

@ -136,5 +136,10 @@ namespace OpenSim.Framework
ISceneObject DeserializeObject(string representation); ISceneObject DeserializeObject(string representation);
bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); bool CheckClient(UUID agentID, System.Net.IPEndPoint ep);
/// <summary>
/// Start the scene and associated scripts within it.
/// </summary>
void Start();
} }
} }

View File

@ -425,9 +425,6 @@ namespace OpenSim
mscene = scene; mscene = scene;
scene.Start();
scene.StartScripts();
return clientServers; return clientServers;
} }
@ -751,6 +748,7 @@ namespace OpenSim
ShutdownClientServer(whichRegion); ShutdownClientServer(whichRegion);
IScene scene; IScene scene;
CreateRegion(whichRegion, true, out scene); CreateRegion(whichRegion, true, out scene);
scene.Start();
} }
# region Setup methods # region Setup methods

View File

@ -389,10 +389,12 @@ namespace OpenSim.Region.Framework.Scenes
if (value) if (value)
{ {
if (!m_active) if (!m_active)
Start(); Start(false);
} }
else else
{ {
// This appears assymetric with Start() above but is not - setting m_active = false stops the loops
// XXX: Possibly this should be in an explicit Stop() method for symmetry.
m_active = false; m_active = false;
} }
} }
@ -1331,10 +1333,18 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public override void Start()
{
Start(true);
}
/// <summary> /// <summary>
/// Start the scene /// Start the scene
/// </summary> /// </summary>
public void Start() /// <param name='startScripts'>
/// Start the scripts within the scene.
/// </param>
public void Start(bool startScripts)
{ {
m_active = true; m_active = true;
@ -1353,6 +1363,8 @@ namespace OpenSim.Region.Framework.Scenes
m_heartbeatThread m_heartbeatThread
= Watchdog.StartThread( = Watchdog.StartThread(
Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false);
StartScripts();
} }
/// <summary> /// <summary>

View File

@ -561,6 +561,10 @@ namespace OpenSim.Region.Framework.Scenes
get { return false; } get { return false; }
} }
public virtual void Start()
{
}
public void Restart() public void Restart()
{ {
// This has to be here to fire the event // This has to be here to fire the event