diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneManager.cs | 233 | ||||
-rw-r--r-- | OpenSim/Services/HypergridService/HGInstantMessageService.cs | 7 |
2 files changed, 143 insertions, 97 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 86ba2aa..069367d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -47,12 +47,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
47 | 47 | ||
48 | public event RestartSim OnRestartSim; | 48 | public event RestartSim OnRestartSim; |
49 | 49 | ||
50 | private readonly List<Scene> m_localScenes; | 50 | private readonly List<Scene> m_localScenes = new List<Scene>(); |
51 | private Scene m_currentScene = null; | 51 | private Scene m_currentScene = null; |
52 | 52 | ||
53 | public List<Scene> Scenes | 53 | public List<Scene> Scenes |
54 | { | 54 | { |
55 | get { return m_localScenes; } | 55 | get { return new List<Scene>(m_localScenes); } |
56 | } | 56 | } |
57 | 57 | ||
58 | public Scene CurrentScene | 58 | public Scene CurrentScene |
@@ -66,13 +66,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
66 | { | 66 | { |
67 | if (m_currentScene == null) | 67 | if (m_currentScene == null) |
68 | { | 68 | { |
69 | if (m_localScenes.Count > 0) | 69 | lock (m_localScenes) |
70 | { | 70 | { |
71 | return m_localScenes[0]; | 71 | if (m_localScenes.Count > 0) |
72 | } | 72 | return m_localScenes[0]; |
73 | else | 73 | else |
74 | { | 74 | return null; |
75 | return null; | ||
76 | } | 75 | } |
77 | } | 76 | } |
78 | else | 77 | else |
@@ -82,26 +81,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
82 | } | 81 | } |
83 | } | 82 | } |
84 | 83 | ||
85 | public SceneManager() | ||
86 | { | ||
87 | m_localScenes = new List<Scene>(); | ||
88 | } | ||
89 | |||
90 | public void Close() | 84 | public void Close() |
91 | { | 85 | { |
92 | // collect known shared modules in sharedModules | 86 | // collect known shared modules in sharedModules |
93 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); | 87 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); |
94 | for (int i = 0; i < m_localScenes.Count; i++) | 88 | |
89 | lock (m_localScenes) | ||
95 | { | 90 | { |
96 | // extract known shared modules from scene | 91 | for (int i = 0; i < m_localScenes.Count; i++) |
97 | foreach (string k in m_localScenes[i].Modules.Keys) | ||
98 | { | 92 | { |
99 | if (m_localScenes[i].Modules[k].IsSharedModule && | 93 | // extract known shared modules from scene |
100 | !sharedModules.ContainsKey(k)) | 94 | foreach (string k in m_localScenes[i].Modules.Keys) |
101 | sharedModules[k] = m_localScenes[i].Modules[k]; | 95 | { |
96 | if (m_localScenes[i].Modules[k].IsSharedModule && | ||
97 | !sharedModules.ContainsKey(k)) | ||
98 | sharedModules[k] = m_localScenes[i].Modules[k]; | ||
99 | } | ||
100 | // close scene/region | ||
101 | m_localScenes[i].Close(); | ||
102 | } | 102 | } |
103 | // close scene/region | ||
104 | m_localScenes[i].Close(); | ||
105 | } | 103 | } |
106 | 104 | ||
107 | // all regions/scenes are now closed, we can now safely | 105 | // all regions/scenes are now closed, we can now safely |
@@ -114,13 +112,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
114 | 112 | ||
115 | public void Close(Scene cscene) | 113 | public void Close(Scene cscene) |
116 | { | 114 | { |
117 | if (m_localScenes.Contains(cscene)) | 115 | lock (m_localScenes) |
118 | { | 116 | { |
119 | for (int i = 0; i < m_localScenes.Count; i++) | 117 | if (m_localScenes.Contains(cscene)) |
120 | { | 118 | { |
121 | if (m_localScenes[i].Equals(cscene)) | 119 | for (int i = 0; i < m_localScenes.Count; i++) |
122 | { | 120 | { |
123 | m_localScenes[i].Close(); | 121 | if (m_localScenes[i].Equals(cscene)) |
122 | { | ||
123 | m_localScenes[i].Close(); | ||
124 | } | ||
124 | } | 125 | } |
125 | } | 126 | } |
126 | } | 127 | } |
@@ -129,27 +130,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | public void Add(Scene scene) | 130 | public void Add(Scene scene) |
130 | { | 131 | { |
131 | scene.OnRestart += HandleRestart; | 132 | scene.OnRestart += HandleRestart; |
132 | m_localScenes.Add(scene); | 133 | |
134 | lock (m_localScenes) | ||
135 | m_localScenes.Add(scene); | ||
133 | } | 136 | } |
134 | 137 | ||
135 | public void HandleRestart(RegionInfo rdata) | 138 | public void HandleRestart(RegionInfo rdata) |
136 | { | 139 | { |
137 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); | 140 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); |
138 | int RegionSceneElement = -1; | 141 | int RegionSceneElement = -1; |
139 | for (int i = 0; i < m_localScenes.Count; i++) | 142 | |
143 | lock (m_localScenes) | ||
140 | { | 144 | { |
141 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | 145 | for (int i = 0; i < m_localScenes.Count; i++) |
142 | { | 146 | { |
143 | RegionSceneElement = i; | 147 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) |
148 | { | ||
149 | RegionSceneElement = i; | ||
150 | } | ||
144 | } | 151 | } |
145 | } | ||
146 | 152 | ||
147 | // Now we make sure the region is no longer known about by the SceneManager | 153 | // Now we make sure the region is no longer known about by the SceneManager |
148 | // Prevents duplicates. | 154 | // Prevents duplicates. |
149 | 155 | ||
150 | if (RegionSceneElement >= 0) | 156 | if (RegionSceneElement >= 0) |
151 | { | 157 | { |
152 | m_localScenes.RemoveAt(RegionSceneElement); | 158 | m_localScenes.RemoveAt(RegionSceneElement); |
159 | } | ||
153 | } | 160 | } |
154 | 161 | ||
155 | // Send signal to main that we're restarting this sim. | 162 | // Send signal to main that we're restarting this sim. |
@@ -160,28 +167,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | { | 167 | { |
161 | RegionInfo Result = null; | 168 | RegionInfo Result = null; |
162 | 169 | ||
163 | for (int i = 0; i < m_localScenes.Count; i++) | 170 | lock (m_localScenes) |
164 | { | ||
165 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) | ||
166 | { | ||
167 | // Inform other regions to tell their avatar about me | ||
168 | Result = m_localScenes[i].RegionInfo; | ||
169 | } | ||
170 | } | ||
171 | if (Result != null) | ||
172 | { | 171 | { |
173 | for (int i = 0; i < m_localScenes.Count; i++) | 172 | for (int i = 0; i < m_localScenes.Count; i++) |
174 | { | 173 | { |
175 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 174 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) |
176 | { | 175 | { |
177 | // Inform other regions to tell their avatar about me | 176 | // Inform other regions to tell their avatar about me |
178 | //m_localScenes[i].OtherRegionUp(Result); | 177 | Result = m_localScenes[i].RegionInfo; |
179 | } | 178 | } |
180 | } | 179 | } |
181 | } | 180 | |
182 | else | 181 | if (Result != null) |
183 | { | 182 | { |
184 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 183 | for (int i = 0; i < m_localScenes.Count; i++) |
184 | { | ||
185 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | ||
186 | { | ||
187 | // Inform other regions to tell their avatar about me | ||
188 | //m_localScenes[i].OtherRegionUp(Result); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | ||
195 | } | ||
185 | } | 196 | } |
186 | } | 197 | } |
187 | 198 | ||
@@ -285,7 +296,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
285 | { | 296 | { |
286 | if (m_currentScene == null) | 297 | if (m_currentScene == null) |
287 | { | 298 | { |
288 | m_localScenes.ForEach(func); | 299 | lock (m_localScenes) |
300 | m_localScenes.ForEach(func); | ||
289 | } | 301 | } |
290 | else | 302 | else |
291 | { | 303 | { |
@@ -314,12 +326,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
314 | } | 326 | } |
315 | else | 327 | else |
316 | { | 328 | { |
317 | foreach (Scene scene in m_localScenes) | 329 | lock (m_localScenes) |
318 | { | 330 | { |
319 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | 331 | foreach (Scene scene in m_localScenes) |
320 | { | 332 | { |
321 | m_currentScene = scene; | 333 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) |
322 | return true; | 334 | { |
335 | m_currentScene = scene; | ||
336 | return true; | ||
337 | } | ||
323 | } | 338 | } |
324 | } | 339 | } |
325 | 340 | ||
@@ -331,12 +346,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
331 | { | 346 | { |
332 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 347 | m_log.Debug("Searching for Region: '" + regionID + "'"); |
333 | 348 | ||
334 | foreach (Scene scene in m_localScenes) | 349 | lock (m_localScenes) |
335 | { | 350 | { |
336 | if (scene.RegionInfo.RegionID == regionID) | 351 | foreach (Scene scene in m_localScenes) |
337 | { | 352 | { |
338 | m_currentScene = scene; | 353 | if (scene.RegionInfo.RegionID == regionID) |
339 | return true; | 354 | { |
355 | m_currentScene = scene; | ||
356 | return true; | ||
357 | } | ||
340 | } | 358 | } |
341 | } | 359 | } |
342 | 360 | ||
@@ -345,26 +363,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
345 | 363 | ||
346 | public bool TryGetScene(string regionName, out Scene scene) | 364 | public bool TryGetScene(string regionName, out Scene scene) |
347 | { | 365 | { |
348 | foreach (Scene mscene in m_localScenes) | 366 | lock (m_localScenes) |
349 | { | 367 | { |
350 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | 368 | foreach (Scene mscene in m_localScenes) |
351 | { | 369 | { |
352 | scene = mscene; | 370 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) |
353 | return true; | 371 | { |
372 | scene = mscene; | ||
373 | return true; | ||
374 | } | ||
354 | } | 375 | } |
355 | } | 376 | } |
377 | |||
356 | scene = null; | 378 | scene = null; |
357 | return false; | 379 | return false; |
358 | } | 380 | } |
359 | 381 | ||
360 | public bool TryGetScene(UUID regionID, out Scene scene) | 382 | public bool TryGetScene(UUID regionID, out Scene scene) |
361 | { | 383 | { |
362 | foreach (Scene mscene in m_localScenes) | 384 | lock (m_localScenes) |
363 | { | 385 | { |
364 | if (mscene.RegionInfo.RegionID == regionID) | 386 | foreach (Scene mscene in m_localScenes) |
365 | { | 387 | { |
366 | scene = mscene; | 388 | if (mscene.RegionInfo.RegionID == regionID) |
367 | return true; | 389 | { |
390 | scene = mscene; | ||
391 | return true; | ||
392 | } | ||
368 | } | 393 | } |
369 | } | 394 | } |
370 | 395 | ||
@@ -374,13 +399,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
374 | 399 | ||
375 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 400 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
376 | { | 401 | { |
377 | foreach (Scene mscene in m_localScenes) | 402 | lock (m_localScenes) |
378 | { | 403 | { |
379 | if (mscene.RegionInfo.RegionLocX == locX && | 404 | foreach (Scene mscene in m_localScenes) |
380 | mscene.RegionInfo.RegionLocY == locY) | ||
381 | { | 405 | { |
382 | scene = mscene; | 406 | if (mscene.RegionInfo.RegionLocX == locX && |
383 | return true; | 407 | mscene.RegionInfo.RegionLocY == locY) |
408 | { | ||
409 | scene = mscene; | ||
410 | return true; | ||
411 | } | ||
384 | } | 412 | } |
385 | } | 413 | } |
386 | 414 | ||
@@ -390,13 +418,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
390 | 418 | ||
391 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 419 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
392 | { | 420 | { |
393 | foreach (Scene mscene in m_localScenes) | 421 | lock (m_localScenes) |
394 | { | 422 | { |
395 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 423 | foreach (Scene mscene in m_localScenes) |
396 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
397 | { | 424 | { |
398 | scene = mscene; | 425 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
399 | return true; | 426 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) |
427 | { | ||
428 | scene = mscene; | ||
429 | return true; | ||
430 | } | ||
400 | } | 431 | } |
401 | } | 432 | } |
402 | 433 | ||
@@ -465,11 +496,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
465 | 496 | ||
466 | public RegionInfo GetRegionInfo(UUID regionID) | 497 | public RegionInfo GetRegionInfo(UUID regionID) |
467 | { | 498 | { |
468 | foreach (Scene scene in m_localScenes) | 499 | lock (m_localScenes) |
469 | { | 500 | { |
470 | if (scene.RegionInfo.RegionID == regionID) | 501 | foreach (Scene scene in m_localScenes) |
471 | { | 502 | { |
472 | return scene.RegionInfo; | 503 | if (scene.RegionInfo.RegionID == regionID) |
504 | { | ||
505 | return scene.RegionInfo; | ||
506 | } | ||
473 | } | 507 | } |
474 | } | 508 | } |
475 | 509 | ||
@@ -488,11 +522,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
488 | 522 | ||
489 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 523 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
490 | { | 524 | { |
491 | foreach (Scene scene in m_localScenes) | 525 | lock (m_localScenes) |
492 | { | 526 | { |
493 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 527 | foreach (Scene scene in m_localScenes) |
494 | { | 528 | { |
495 | return true; | 529 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
530 | { | ||
531 | return true; | ||
532 | } | ||
496 | } | 533 | } |
497 | } | 534 | } |
498 | 535 | ||
@@ -503,12 +540,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
503 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) | 540 | public bool TryGetAvatarsScene(UUID avatarId, out Scene scene) |
504 | { | 541 | { |
505 | ScenePresence avatar = null; | 542 | ScenePresence avatar = null; |
506 | foreach (Scene mScene in m_localScenes) | 543 | |
544 | lock (m_localScenes) | ||
507 | { | 545 | { |
508 | if (mScene.TryGetScenePresence(avatarId, out avatar)) | 546 | foreach (Scene mScene in m_localScenes) |
509 | { | 547 | { |
510 | scene = mScene; | 548 | if (mScene.TryGetScenePresence(avatarId, out avatar)) |
511 | return true; | 549 | { |
550 | scene = mScene; | ||
551 | return true; | ||
552 | } | ||
512 | } | 553 | } |
513 | } | 554 | } |
514 | 555 | ||
@@ -518,17 +559,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
518 | 559 | ||
519 | public void CloseScene(Scene scene) | 560 | public void CloseScene(Scene scene) |
520 | { | 561 | { |
521 | m_localScenes.Remove(scene); | 562 | lock (m_localScenes) |
563 | m_localScenes.Remove(scene); | ||
564 | |||
522 | scene.Close(); | 565 | scene.Close(); |
523 | } | 566 | } |
524 | 567 | ||
525 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 568 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
526 | { | 569 | { |
527 | foreach (Scene scene in m_localScenes) | 570 | lock (m_localScenes) |
528 | { | 571 | { |
529 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 572 | foreach (Scene scene in m_localScenes) |
530 | { | 573 | { |
531 | return true; | 574 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
575 | { | ||
576 | return true; | ||
577 | } | ||
532 | } | 578 | } |
533 | } | 579 | } |
534 | 580 | ||
@@ -538,7 +584,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
538 | 584 | ||
539 | public void ForEachScene(Action<Scene> action) | 585 | public void ForEachScene(Action<Scene> action) |
540 | { | 586 | { |
541 | m_localScenes.ForEach(action); | 587 | lock (m_localScenes) |
588 | m_localScenes.ForEach(action); | ||
542 | } | 589 | } |
543 | } | 590 | } |
544 | } | 591 | } \ No newline at end of file |
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index bb31fc9..0d59636 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs | |||
@@ -95,7 +95,6 @@ namespace OpenSim.Services.HypergridService | |||
95 | m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false); | 95 | m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false); |
96 | m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper); | 96 | m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper); |
97 | 97 | ||
98 | |||
99 | if (gridService == string.Empty || presenceService == string.Empty) | 98 | if (gridService == string.Empty || presenceService == string.Empty) |
100 | throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function.")); | 99 | throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function.")); |
101 | 100 | ||
@@ -120,7 +119,7 @@ namespace OpenSim.Services.HypergridService | |||
120 | 119 | ||
121 | public bool IncomingInstantMessage(GridInstantMessage im) | 120 | public bool IncomingInstantMessage(GridInstantMessage im) |
122 | { | 121 | { |
123 | m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID); | 122 | // m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID); |
124 | UUID toAgentID = new UUID(im.toAgentID); | 123 | UUID toAgentID = new UUID(im.toAgentID); |
125 | 124 | ||
126 | bool success = false; | 125 | bool success = false; |
@@ -142,7 +141,7 @@ namespace OpenSim.Services.HypergridService | |||
142 | 141 | ||
143 | public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner) | 142 | public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner) |
144 | { | 143 | { |
145 | m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url); | 144 | // m_log.DebugFormat("[HG IM SERVICE]: Sending message from {0} to {1}@{2}", im.fromAgentID, im.toAgentID, url); |
146 | if (url != string.Empty) | 145 | if (url != string.Empty) |
147 | return TrySendInstantMessage(im, url, true, foreigner); | 146 | return TrySendInstantMessage(im, url, true, foreigner); |
148 | else | 147 | else |
@@ -333,7 +332,7 @@ namespace OpenSim.Services.HypergridService | |||
333 | if (m_RestURL != string.Empty && (im.offline != 0) | 332 | if (m_RestURL != string.Empty && (im.offline != 0) |
334 | && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) | 333 | && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) |
335 | { | 334 | { |
336 | m_log.DebugFormat("[HG IM SERVICE]: Message saved"); | 335 | // m_log.DebugFormat("[HG IM SERVICE]: Message saved"); |
337 | 336 | ||
338 | return SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | 337 | return SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( |
339 | "POST", m_RestURL + "/SaveMessage/", im); | 338 | "POST", m_RestURL + "/SaveMessage/", im); |