Do proper locking of m_localScenes list in SceneManager
parent
dad1d6df18
commit
76f46b2545
|
@ -47,12 +47,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public event RestartSim OnRestartSim;
|
||||
|
||||
private readonly List<Scene> m_localScenes;
|
||||
private readonly List<Scene> m_localScenes = new List<Scene>();
|
||||
private Scene m_currentScene = null;
|
||||
|
||||
public List<Scene> Scenes
|
||||
{
|
||||
get { return m_localScenes; }
|
||||
get { return new List<Scene>(m_localScenes); }
|
||||
}
|
||||
|
||||
public Scene CurrentScene
|
||||
|
@ -65,13 +65,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
get
|
||||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
if (m_localScenes.Count > 0)
|
||||
{
|
||||
return m_localScenes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -82,15 +81,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public SceneManager()
|
||||
{
|
||||
m_localScenes = new List<Scene>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
// collect known shared modules in sharedModules
|
||||
Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>();
|
||||
|
||||
lock (m_localScenes)
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
// extract known shared modules from scene
|
||||
|
@ -103,6 +100,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// close scene/region
|
||||
m_localScenes[i].Close();
|
||||
}
|
||||
}
|
||||
|
||||
// all regions/scenes are now closed, we can now safely
|
||||
// close all shared modules
|
||||
|
@ -113,6 +111,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
|
||||
public void Close(Scene cscene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
if (m_localScenes.Contains(cscene))
|
||||
{
|
||||
|
@ -125,10 +125,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Scene scene)
|
||||
{
|
||||
scene.OnRestart += HandleRestart;
|
||||
|
||||
lock (m_localScenes)
|
||||
m_localScenes.Add(scene);
|
||||
}
|
||||
|
||||
|
@ -136,6 +139,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main");
|
||||
int RegionSceneElement = -1;
|
||||
|
||||
lock (m_localScenes)
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
|
||||
|
@ -151,6 +157,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
m_localScenes.RemoveAt(RegionSceneElement);
|
||||
}
|
||||
}
|
||||
|
||||
// Send signal to main that we're restarting this sim.
|
||||
OnRestartSim(rdata);
|
||||
|
@ -160,6 +167,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
RegionInfo Result = null;
|
||||
|
||||
lock (m_localScenes)
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
{
|
||||
if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle)
|
||||
|
@ -168,6 +177,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
Result = m_localScenes[i].RegionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (Result != null)
|
||||
{
|
||||
for (int i = 0; i < m_localScenes.Count; i++)
|
||||
|
@ -184,6 +194,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the prims in the current scene to an xml file in OpenSimulator's original 'xml' format
|
||||
|
@ -285,6 +296,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
if (m_currentScene == null)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
m_localScenes.ForEach(func);
|
||||
}
|
||||
else
|
||||
|
@ -313,6 +325,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
|
@ -322,6 +336,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -331,6 +346,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
m_log.Debug("Searching for Region: '" + regionID + "'");
|
||||
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
if (scene.RegionInfo.RegionID == regionID)
|
||||
|
@ -339,11 +356,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(string regionName, out Scene scene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
|
@ -353,11 +373,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(UUID regionID, out Scene scene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
|
@ -367,12 +391,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(uint locX, uint locY, out Scene scene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
|
@ -383,12 +410,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene mscene in m_localScenes)
|
||||
{
|
||||
|
@ -399,6 +429,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
|
@ -464,6 +495,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
|
||||
public RegionInfo GetRegionInfo(UUID regionID)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
|
@ -472,6 +505,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return scene.RegionInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -487,6 +521,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
|
||||
public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
|
@ -495,6 +531,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
|
@ -503,6 +540,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public bool TryGetAvatarsScene(UUID avatarId, out Scene scene)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene mScene in m_localScenes)
|
||||
{
|
||||
if (mScene.TryGetScenePresence(avatarId, out avatar))
|
||||
|
@ -511,6 +551,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene = null;
|
||||
return false;
|
||||
|
@ -518,11 +559,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void CloseScene(Scene scene)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
m_localScenes.Remove(scene);
|
||||
|
||||
scene.Close();
|
||||
}
|
||||
|
||||
public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
{
|
||||
foreach (Scene scene in m_localScenes)
|
||||
{
|
||||
|
@ -531,6 +576,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
avatar = null;
|
||||
return false;
|
||||
|
@ -538,6 +584,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void ForEachScene(Action<Scene> action)
|
||||
{
|
||||
lock (m_localScenes)
|
||||
m_localScenes.ForEach(action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,6 @@ namespace OpenSim.Services.HypergridService
|
|||
m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false);
|
||||
m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper);
|
||||
|
||||
|
||||
if (gridService == string.Empty || presenceService == string.Empty)
|
||||
throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function."));
|
||||
|
||||
|
@ -120,7 +119,7 @@ namespace OpenSim.Services.HypergridService
|
|||
|
||||
public bool IncomingInstantMessage(GridInstantMessage im)
|
||||
{
|
||||
m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
|
||||
// m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
|
||||
UUID toAgentID = new UUID(im.toAgentID);
|
||||
|
||||
bool success = false;
|
||||
|
@ -142,7 +141,7 @@ namespace OpenSim.Services.HypergridService
|
|||
|
||||
public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
|
||||
{
|
||||
m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
|
||||
// m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url);
|
||||
if (url != string.Empty)
|
||||
return TrySendInstantMessage(im, url, true, foreigner);
|
||||
else
|
||||
|
@ -333,7 +332,7 @@ namespace OpenSim.Services.HypergridService
|
|||
if (m_RestURL != string.Empty && (im.offline != 0)
|
||||
&& (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
|
||||
{
|
||||
m_log.DebugFormat("[HG IM SERVICE]: Message saved");
|
||||
// m_log.DebugFormat("[HG IM SERVICE]: Message saved");
|
||||
|
||||
return SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
|
||||
"POST", m_RestURL + "/SaveMessage/", im);
|
||||
|
|
Loading…
Reference in New Issue