aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest
diff options
context:
space:
mode:
authorDan Lake2010-03-19 05:51:16 -0700
committerJohn Hurliman2010-03-19 15:16:35 -0700
commit859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046 (patch)
treedcce6c74d201b52c1a04ec9ec2cb90ce068fc020 /OpenSim/ApplicationPlugins/Rest
parentInconsistent locking of ScenePresence array in SceneGraph. Fixed by eliminati... (diff)
downloadopensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.zip
opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.tar.gz
opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.tar.bz2
opensim-SC_OLD-859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046.tar.xz
Cleaned up access to scenepresences in scenegraph. GetScenePresences and GetAvatars have been removed to consolidate locking and iteration within SceneGraph. All callers which used these to then iterate over presences have been refactored to instead pass their delegates to Scene.ForEachScenePresence(Action<ScenePresence>).
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs36
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs2
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs2
3 files changed, 18 insertions, 22 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs
index b15b337..4333ef1 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs
@@ -123,10 +123,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
123 123
124 private void DoMove(RequestData rdata) 124 private void DoMove(RequestData rdata)
125 { 125 {
126 if (rdata.Parameters.Length >= 6) 126 if (rdata.Parameters.Length < 6)
127 {
128 Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
129 rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
130 }
131 else
127 { 132 {
128 string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE); 133 string[] names = rdata.Parameters[PARM_MOVE_AVATAR].Split(Rest.CA_SPACE);
129 ScenePresence avatar = null; 134 ScenePresence presence = null;
130 Scene scene = null; 135 Scene scene = null;
131 136
132 if (names.Length != 2) 137 if (names.Length != 2)
@@ -141,21 +146,19 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
141 // The first parameter should be an avatar name, look for the 146 // The first parameter should be an avatar name, look for the
142 // avatar in the known regions first. 147 // avatar in the known regions first.
143 148
144 foreach (Scene cs in Rest.main.SceneManager.Scenes) 149 Rest.main.SceneManager.ForEachScene(delegate(Scene s)
145 { 150 {
146 foreach (ScenePresence presence in cs.GetAvatars()) 151 s.ForEachScenePresence(delegate(ScenePresence sp)
147 { 152 {
148 if (presence.Firstname == names[0] && 153 if (sp.Firstname == names[0] && sp.Lastname == names[1])
149 presence.Lastname == names[1])
150 { 154 {
151 scene = cs; 155 scene = s;
152 avatar = presence; 156 presence = sp;
153 break;
154 } 157 }
155 } 158 });
156 } 159 });
157 160
158 if (avatar != null) 161 if (presence != null)
159 { 162 {
160 Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}", 163 Rest.Log.DebugFormat("{0} Move : Avatar {1} located in region {2}",
161 MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName); 164 MsgId, rdata.Parameters[PARM_MOVE_AVATAR], scene.RegionInfo.RegionName);
@@ -166,14 +169,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
166 float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]); 169 float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]);
167 float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); 170 float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]);
168 Vector3 vector = new Vector3(x,y,z); 171 Vector3 vector = new Vector3(x,y,z);
169 avatar.DoAutoPilot(0,vector,avatar.ControllingClient); 172 presence.DoAutoPilot(0,vector,presence.ControllingClient);
170 } 173 }
171 catch (Exception e) 174 catch (Exception e)
172 { 175 {
173 rdata.Fail(Rest.HttpStatusCodeBadRequest, 176 rdata.Fail(Rest.HttpStatusCodeBadRequest,
174 String.Format("invalid parameters: {0}", e.Message)); 177 String.Format("invalid parameters: {0}", e.Message));
175 } 178 }
176
177 } 179 }
178 else 180 else
179 { 181 {
@@ -183,12 +185,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
183 185
184 rdata.Complete(); 186 rdata.Complete();
185 rdata.Respond("OK"); 187 rdata.Respond("OK");
186
187 }
188 else
189 {
190 Rest.Log.WarnFormat("{0} Move: No movement information provided", MsgId);
191 rdata.Fail(Rest.HttpStatusCodeBadRequest, "no movement information provided");
192 } 188 }
193 } 189 }
194 190
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
index ed18207..dea166d 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
@@ -192,7 +192,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
192 192
193 protected string RegionStats(OSHttpResponse httpResponse, Scene scene) 193 protected string RegionStats(OSHttpResponse httpResponse, Scene scene)
194 { 194 {
195 int users = scene.GetAvatars().Count; 195 int users = scene.GetRootAgentCount();
196 int objects = scene.Entities.Count - users; 196 int objects = scene.Entities.Count - users;
197 197
198 RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); 198 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
index 734b668..279db4c 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
@@ -117,7 +117,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
117 rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); 117 rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
118 rxw.WriteEndAttribute(); 118 rxw.WriteEndAttribute();
119 119
120 int users = s.GetAvatars().Count; 120 int users = s.GetRootAgentCount();
121 rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); 121 rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
122 rxw.WriteValue(users); 122 rxw.WriteValue(users);
123 rxw.WriteEndAttribute(); 123 rxw.WriteEndAttribute();