change use of lock

master
Christopher Latza 2020-06-19 20:44:56 +02:00
parent e3c230c2f8
commit 767e7c48b1
1 changed files with 66 additions and 66 deletions

View File

@ -145,57 +145,57 @@ namespace OpenSim.Modules.PathFinding
private void generatePathEnvironment(ScriptRequestData requestData) private void generatePathEnvironment(ScriptRequestData requestData)
{ {
try lock(m_environments)
{ {
UUID _envID = UUID.Random(); try
Environment _newEnv = new Environment(_envID.ToString(), (int)m_scene.RegionInfo.RegionSizeX);
lock (m_environments)
{ {
m_environments.Add(_newEnv); UUID _envID = UUID.Random();
} Environment _newEnv = new Environment(_envID.ToString(), (int)m_scene.RegionInfo.RegionSizeX);
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, _envID.ToString(), requestData.RequestID.ToString()); m_environments.Add(_newEnv);
}
catch(Exception _error) m_scriptModule.DispatchReply(requestData.ScriptID, 19850, _envID.ToString(), requestData.RequestID.ToString());
{ }
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString()); catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
} }
} }
private void keepAlivePathEnv(ScriptRequestData requestData) private void keepAlivePathEnv(ScriptRequestData requestData)
{ {
try lock (m_environments)
{ {
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID); try
if (_env != null)
{ {
lock(_env) Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{ {
_env.LastTimeUsed = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; _env.LastTimeUsed = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
return; return;
} }
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
} }
catch (Exception _error) catch (Exception _error)
{ {
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
} }
} }
private void removeAllTargets(ScriptRequestData requestData) private void removeAllTargets(ScriptRequestData requestData)
{ {
try lock(m_environments)
{ {
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID); try
if (_env != null)
{ {
lock(_env) Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{ {
List<PathNode> _nodes = _env.Nodes.FindAll(X => X.Target == true); List<PathNode> _nodes = _env.Nodes.FindAll(X => X.Target == true);
@ -205,22 +205,22 @@ namespace OpenSim.Modules.PathFinding
} }
} }
} }
} catch (Exception _error)
catch (Exception _error) {
{ m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString()); }
} }
} }
private void setPositionData(ScriptRequestData requestData, Vector3 position, int walkable, int isTarget) private void setPositionData(ScriptRequestData requestData, Vector3 position, int walkable, int isTarget)
{ {
try lock(m_environments)
{ {
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID); try
if (_env != null)
{ {
lock(_env) Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{ {
if (isTarget == 1) if (isTarget == 1)
removeAllTargets(requestData); removeAllTargets(requestData);
@ -247,25 +247,25 @@ namespace OpenSim.Modules.PathFinding
return; return;
} }
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
} }
catch (Exception _error) catch (Exception _error)
{ {
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
} }
} }
private void setLineData(ScriptRequestData requestData, Vector3 start, Vector3 target, int walkable) private void setLineData(ScriptRequestData requestData, Vector3 start, Vector3 target, int walkable)
{ {
try lock(m_environments)
{ {
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID); try
if (_env != null)
{ {
lock(_env) Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{ {
if ((int)start.X == (int)target.X || (int)start.Y == (int)target.Y) if ((int)start.X == (int)target.X || (int)start.Y == (int)target.Y)
{ {
@ -328,16 +328,16 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19853, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19853, "", requestData.RequestID.ToString());
} }
} }
else
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
}
} }
else catch (Exception _error)
{ {
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
} }
} }
catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
} }
private void generatePath(ScriptRequestData requestData) private void generatePath(ScriptRequestData requestData)
@ -347,13 +347,13 @@ namespace OpenSim.Modules.PathFinding
private void generateDebugImage(ScriptRequestData requestData) private void generateDebugImage(ScriptRequestData requestData)
{ {
try lock(m_environments)
{ {
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID); try
if (_env != null)
{ {
lock (_env) Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{ {
Bitmap _bitmap = new Bitmap(_env.Size, _env.Size); Bitmap _bitmap = new Bitmap(_env.Size, _env.Size);
@ -370,16 +370,16 @@ namespace OpenSim.Modules.PathFinding
} }
_bitmap.Save(requestData.EnvironmentID + ".png"); _bitmap.Save(requestData.EnvironmentID + ".png");
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19850, requestData.EnvironmentID + ".png", requestData.RequestID.ToString());
return; return;
} }
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
} }
catch (Exception _error) catch (Exception _error)
{ {
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString()); m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
} }
} }