aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Monitoring/BaseStatsCollector.cs21
-rw-r--r--OpenSim/Framework/Monitoring/JobEngine.cs111
-rw-r--r--OpenSim/Framework/Monitoring/Watchdog.cs18
-rw-r--r--OpenSim/Framework/Util.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs45
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs54
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs68
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs133
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs4
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs31
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs1
17 files changed, 286 insertions, 262 deletions
diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
index 96536e8..8c2bec6 100644
--- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
+++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs
@@ -56,22 +56,25 @@ namespace OpenSim.Framework.Monitoring
56 Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3)); 56 Math.Round((MemoryWatchdog.AverageHeapAllocationRate * 1000) / 1024.0 / 1024, 3));
57 57
58 Process myprocess = Process.GetCurrentProcess(); 58 Process myprocess = Process.GetCurrentProcess();
59 if (!myprocess.HasExited) 59// if (!myprocess.HasExited)
60 try
60 { 61 {
61 myprocess.Refresh(); 62 myprocess.Refresh();
62 sb.AppendFormat( 63 sb.AppendFormat(
63 "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", 64 "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
64 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0), 65 Math.Round(myprocess.WorkingSet64 / 1024.0 / 1024.0),
65 Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0), 66 Math.Round(myprocess.PagedMemorySize64 / 1024.0 / 1024.0),
66 Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0)); 67 Math.Round(myprocess.VirtualMemorySize64 / 1024.0 / 1024.0));
67 sb.AppendFormat( 68 sb.AppendFormat(
68 "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", 69 "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
69 Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0), 70 Math.Round(myprocess.PeakWorkingSet64 / 1024.0 / 1024.0),
70 Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0), 71 Math.Round(myprocess.PeakPagedMemorySize64 / 1024.0 / 1024.0),
71 Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0)); 72 Math.Round(myprocess.PeakVirtualMemorySize64 / 1024.0 / 1024.0));
72 } 73 }
73 else 74 catch
74 sb.Append("Process reported as Exited \n"); 75 { }
76// else
77// sb.Append("Process reported as Exited \n");
75 78
76 return sb.ToString(); 79 return sb.ToString();
77 } 80 }
diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs
index 6db9a67..7709f62 100644
--- a/OpenSim/Framework/Monitoring/JobEngine.cs
+++ b/OpenSim/Framework/Monitoring/JobEngine.cs
@@ -40,6 +40,8 @@ namespace OpenSim.Framework.Monitoring
40 40
41 public int LogLevel { get; set; } 41 public int LogLevel { get; set; }
42 42
43 private object JobLock = new object();
44
43 public string Name { get; private set; } 45 public string Name { get; private set; }
44 46
45 public string LoggingName { get; private set; } 47 public string LoggingName { get; private set; }
@@ -76,7 +78,7 @@ namespace OpenSim.Framework.Monitoring
76 /// </remarks> 78 /// </remarks>
77 private bool m_warnOverMaxQueue = true; 79 private bool m_warnOverMaxQueue = true;
78 80
79 private BlockingCollection<Job> m_jobQueue; 81 private BlockingCollection<Job> m_jobQueue = new BlockingCollection<Job>(new ConcurrentQueue<Job>(), 5000);
80 82
81 private CancellationTokenSource m_cancelSource; 83 private CancellationTokenSource m_cancelSource;
82 84
@@ -95,7 +97,7 @@ namespace OpenSim.Framework.Monitoring
95 97
96 public void Start() 98 public void Start()
97 { 99 {
98 lock (this) 100 lock (JobLock)
99 { 101 {
100 if (IsRunning) 102 if (IsRunning)
101 return; 103 return;
@@ -104,7 +106,6 @@ namespace OpenSim.Framework.Monitoring
104 106
105 m_finishedProcessingAfterStop.Reset(); 107 m_finishedProcessingAfterStop.Reset();
106 108
107 m_jobQueue = new BlockingCollection<Job>(new ConcurrentQueue<Job>(), 5000);
108 m_cancelSource = new CancellationTokenSource(); 109 m_cancelSource = new CancellationTokenSource();
109 110
110 WorkManager.StartThread( 111 WorkManager.StartThread(
@@ -120,43 +121,22 @@ namespace OpenSim.Framework.Monitoring
120 121
121 public void Stop() 122 public void Stop()
122 { 123 {
123 lock (this) 124 lock (JobLock)
124 { 125 {
125 try 126 try
126 { 127 {
127 if (!IsRunning) 128 if (!IsRunning)
128 return; 129 return;
129 130
130 IsRunning = false; 131 m_log.DebugFormat("[JobEngine] Stopping {0}", Name);
131 132
132 int requestsLeft = m_jobQueue.Count; 133 IsRunning = false;
133 134
134 if (requestsLeft <= 0) 135 m_finishedProcessingAfterStop.Reset();
135 { 136 if(m_jobQueue.Count <= 0)
136 m_cancelSource.Cancel(); 137 m_cancelSource.Cancel();
137 } 138
138 else 139 m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop);
139 {
140 m_log.InfoFormat("[{0}]: Waiting to write {1} events after stop.", LoggingName, requestsLeft);
141
142 while (requestsLeft > 0)
143 {
144 if (!m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop))
145 {
146 // After timeout no events have been written
147 if (requestsLeft == m_jobQueue.Count)
148 {
149 m_log.WarnFormat(
150 "[{0}]: No requests processed after {1} ms wait. Discarding remaining {2} requests",
151 LoggingName, RequestProcessTimeoutOnStop, requestsLeft);
152
153 break;
154 }
155 }
156
157 requestsLeft = m_jobQueue.Count;
158 }
159 }
160 } 140 }
161 finally 141 finally
162 { 142 {
@@ -245,48 +225,51 @@ namespace OpenSim.Framework.Monitoring
245 225
246 private void ProcessRequests() 226 private void ProcessRequests()
247 { 227 {
248 try 228 while(IsRunning || m_jobQueue.Count > 0)
249 { 229 {
250 while (IsRunning || m_jobQueue.Count > 0) 230 try
251 { 231 {
252 try 232 CurrentJob = m_jobQueue.Take(m_cancelSource.Token);
253 { 233 }
254 CurrentJob = m_jobQueue.Take(m_cancelSource.Token); 234 catch(ObjectDisposedException e)
255 } 235 {
256 catch (ObjectDisposedException e) 236 // If we see this whilst not running then it may be due to a race where this thread checks
237 // IsRunning after the stopping thread sets it to false and disposes of the cancellation source.
238 if(IsRunning)
239 throw e;
240 else
257 { 241 {
258 // If we see this whilst not running then it may be due to a race where this thread checks 242 m_log.DebugFormat("[JobEngine] {0} stopping ignoring {1} jobs in queue",
259 // IsRunning after the stopping thread sets it to false and disposes of the cancellation source. 243 Name,m_jobQueue.Count);
260 if (IsRunning) 244 break;
261 throw e;
262 else
263 break;
264 } 245 }
246 }
247 catch(OperationCanceledException)
248 {
249 break;
250 }
265 251
266 if (LogLevel >= 1) 252 if(LogLevel >= 1)
267 m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name); 253 m_log.DebugFormat("[{0}]: Processing job {1}",LoggingName,CurrentJob.Name);
268 254
269 try 255 try
270 { 256 {
271 CurrentJob.Action(); 257 CurrentJob.Action();
272 } 258 }
273 catch (Exception e) 259 catch(Exception e)
274 { 260 {
275 m_log.Error( 261 m_log.Error(
276 string.Format( 262 string.Format(
277 "[{0}]: Job {1} failed, continuing. Exception ", LoggingName, CurrentJob.Name), e); 263 "[{0}]: Job {1} failed, continuing. Exception ",LoggingName,CurrentJob.Name),e);
278 } 264 }
279 265
280 if (LogLevel >= 1) 266 if(LogLevel >= 1)
281 m_log.DebugFormat("[{0}]: Processed job {1}", LoggingName, CurrentJob.Name); 267 m_log.DebugFormat("[{0}]: Processed job {1}",LoggingName,CurrentJob.Name);
282 268
283 CurrentJob = null; 269 CurrentJob = null;
284 }
285 }
286 catch (OperationCanceledException)
287 {
288 } 270 }
289 271
272 Watchdog.RemoveThread(false);
290 m_finishedProcessingAfterStop.Set(); 273 m_finishedProcessingAfterStop.Set();
291 } 274 }
292 275
@@ -338,4 +321,4 @@ namespace OpenSim.Framework.Monitoring
338 } 321 }
339 } 322 }
340 } 323 }
341} \ No newline at end of file 324}
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index 4485a9c..b2c1fb1 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -332,29 +332,31 @@ namespace OpenSim.Framework.Monitoring
332 if (callback != null) 332 if (callback != null)
333 { 333 {
334 List<ThreadWatchdogInfo> callbackInfos = null; 334 List<ThreadWatchdogInfo> callbackInfos = null;
335 List<ThreadWatchdogInfo> threadsInfo;
335 336
336 lock (m_threads) 337 lock (m_threads)
337 { 338 {
338 // get a copy since we may change m_threads 339 // get a copy since we may change m_threads
339 List<ThreadWatchdogInfo> threadsInfo = m_threads.Values.ToList(); 340 threadsInfo = m_threads.Values.ToList();
340 foreach (ThreadWatchdogInfo threadInfo in threadsInfo) 341
342 foreach(ThreadWatchdogInfo threadInfo in threadsInfo)
341 { 343 {
342 if (threadInfo.Thread.ThreadState == ThreadState.Stopped) 344 if(threadInfo.Thread.ThreadState == ThreadState.Stopped)
343 { 345 {
344 RemoveThread(threadInfo.Thread.ManagedThreadId); 346 RemoveThread(threadInfo.Thread.ManagedThreadId);
345 347
346 if (callbackInfos == null) 348 if(callbackInfos == null)
347 callbackInfos = new List<ThreadWatchdogInfo>(); 349 callbackInfos = new List<ThreadWatchdogInfo>();
348 350
349 callbackInfos.Add(threadInfo); 351 callbackInfos.Add(threadInfo);
350 } 352 }
351 else if (!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) 353 else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout)
352 { 354 {
353 threadInfo.IsTimedOut = true; 355 threadInfo.IsTimedOut = true;
354 356
355 if (threadInfo.AlarmIfTimeout) 357 if(threadInfo.AlarmIfTimeout)
356 { 358 {
357 if (callbackInfos == null) 359 if(callbackInfos == null)
358 callbackInfos = new List<ThreadWatchdogInfo>(); 360 callbackInfos = new List<ThreadWatchdogInfo>();
359 361
360 // Send a copy of the watchdog info to prevent race conditions where the watchdog 362 // Send a copy of the watchdog info to prevent race conditions where the watchdog
@@ -365,7 +367,7 @@ namespace OpenSim.Framework.Monitoring
365 } 367 }
366 } 368 }
367 369
368 if (callbackInfos != null) 370 if(callbackInfos != null)
369 foreach (ThreadWatchdogInfo callbackInfo in callbackInfos) 371 foreach (ThreadWatchdogInfo callbackInfo in callbackInfos)
370 callback(callbackInfo); 372 callback(callbackInfo);
371 } 373 }
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 4dafaef..4aad578 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -753,7 +753,7 @@ namespace OpenSim.Framework
753 newy *= Constants.RegionSize; 753 newy *= Constants.RegionSize;
754 if (oldy + oldsizey + drawdist < newy) 754 if (oldy + oldsizey + drawdist < newy)
755 return true; 755 return true;
756 if (newy + newsizey + drawdist< oldy) 756 if (newy + newsizey + drawdist < oldy)
757 return true; 757 return true;
758 758
759 return false; 759 return false;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index b5a70040..95d9c99 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Region.ClientStack.Linden
88 88
89 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 89 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
90 private static Thread[] m_workerThreads = null; 90 private static Thread[] m_workerThreads = null;
91 91 private static int m_NumberScenes = 0;
92 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = 92 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
93 new OpenMetaverse.BlockingQueue<aPollRequest>(); 93 new OpenMetaverse.BlockingQueue<aPollRequest>();
94 94
@@ -97,13 +97,6 @@ namespace OpenSim.Region.ClientStack.Linden
97 97
98 #region Region Module interfaceBase Members 98 #region Region Module interfaceBase Members
99 99
100 ~GetMeshModule()
101 {
102 foreach (Thread t in m_workerThreads)
103 Watchdog.AbortThread(t.ManagedThreadId);
104
105 }
106
107 public Type ReplaceableInterface 100 public Type ReplaceableInterface
108 { 101 {
109 get { return null; } 102 get { return null; }
@@ -151,7 +144,7 @@ namespace OpenSim.Region.ClientStack.Linden
151 m_scene.EventManager.OnRegisterCaps -= RegisterCaps; 144 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
152 m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; 145 m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
153 m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate; 146 m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate;
154 147 m_NumberScenes--;
155 m_scene = null; 148 m_scene = null;
156 } 149 }
157 150
@@ -167,6 +160,8 @@ namespace OpenSim.Region.ClientStack.Linden
167 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; 160 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
168 m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; 161 m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate;
169 162
163 m_NumberScenes++;
164
170 if (m_workerThreads == null) 165 if (m_workerThreads == null)
171 { 166 {
172 m_workerThreads = new Thread[2]; 167 m_workerThreads = new Thread[2];
@@ -174,7 +169,7 @@ namespace OpenSim.Region.ClientStack.Linden
174 for (uint i = 0; i < 2; i++) 169 for (uint i = 0; i < 2; i++)
175 { 170 {
176 m_workerThreads[i] = WorkManager.StartThread(DoMeshRequests, 171 m_workerThreads[i] = WorkManager.StartThread(DoMeshRequests,
177 String.Format("MeshWorkerThread{0}", i), 172 String.Format("GetMeshWorker{0}", i),
178 ThreadPriority.Normal, 173 ThreadPriority.Normal,
179 false, 174 false,
180 false, 175 false,
@@ -182,22 +177,29 @@ namespace OpenSim.Region.ClientStack.Linden
182 int.MaxValue); 177 int.MaxValue);
183 } 178 }
184 } 179 }
185
186 } 180 }
187 181
188 182 public void Close()
189 public void Close() { } 183 {
184 if(m_NumberScenes <= 0 && m_workerThreads != null)
185 {
186 m_log.DebugFormat("[GetMeshModule] Closing");
187 foreach (Thread t in m_workerThreads)
188 Watchdog.AbortThread(t.ManagedThreadId);
189 m_queue.Clear();
190 }
191 }
190 192
191 public string Name { get { return "GetMeshModule"; } } 193 public string Name { get { return "GetMeshModule"; } }
192 194
193 #endregion 195 #endregion
194 196
195 private void DoMeshRequests() 197 private static void DoMeshRequests()
196 { 198 {
197 while (true) 199 while(true)
198 { 200 {
199 aPollRequest poolreq = m_queue.Dequeue(); 201 aPollRequest poolreq = m_queue.Dequeue();
200 202 Watchdog.UpdateThread();
201 poolreq.thepoll.Process(poolreq); 203 poolreq.thepoll.Process(poolreq);
202 } 204 }
203 } 205 }
@@ -293,6 +295,9 @@ namespace OpenSim.Region.ClientStack.Linden
293 295
294 UUID requestID = requestinfo.reqID; 296 UUID requestID = requestinfo.reqID;
295 297
298 if(m_scene.ShuttingDown)
299 return;
300
296 // If the avatar is gone, don't bother to get the texture 301 // If the avatar is gone, don't bother to get the texture
297 if (m_scene.GetScenePresence(Id) == null) 302 if (m_scene.GetScenePresence(Id) == null)
298 { 303 {
@@ -386,7 +391,7 @@ namespace OpenSim.Region.ClientStack.Linden
386 private volatile int BytesSent = 0; 391 private volatile int BytesSent = 0;
387 private int Lod3 = 0; 392 private int Lod3 = 0;
388 private int Lod2 = 0; 393 private int Lod2 = 0;
389 private int Lod1 = 0; 394// private int Lod1 = 0;
390 private int UserSetThrottle = 0; 395 private int UserSetThrottle = 0;
391 private int UDPSetThrottle = 0; 396 private int UDPSetThrottle = 0;
392 private int CapSetThrottle = 0; 397 private int CapSetThrottle = 0;
@@ -404,7 +409,6 @@ namespace OpenSim.Region.ClientStack.Linden
404 User = puser; 409 User = puser;
405 } 410 }
406 411
407
408 public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses) 412 public bool hasEvents(UUID key, Dictionary<UUID, aPollResponse> responses)
409 { 413 {
410 const float ThirtyPercent = 0.30f; 414 const float ThirtyPercent = 0.30f;
@@ -486,7 +490,6 @@ namespace OpenSim.Region.ClientStack.Linden
486 PassTime(); 490 PassTime();
487 } 491 }
488 492
489
490 private void PassTime() 493 private void PassTime()
491 { 494 {
492 currenttime = Util.EnvironmentTickCount(); 495 currenttime = Util.EnvironmentTickCount();
@@ -501,10 +504,11 @@ namespace OpenSim.Region.ClientStack.Linden
501 { 504 {
502 Lod3 = 0; 505 Lod3 = 0;
503 Lod2 = 0; 506 Lod2 = 0;
504 Lod1 = 0; 507// Lod1 = 0;
505 } 508 }
506 } 509 }
507 } 510 }
511
508 private void AlterThrottle(int setting, ScenePresence p) 512 private void AlterThrottle(int setting, ScenePresence p)
509 { 513 {
510 p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); 514 p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting);
@@ -534,6 +538,5 @@ namespace OpenSim.Region.ClientStack.Linden
534 538
535 } 539 }
536 } 540 }
537
538 } 541 }
539} 542}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
index aa51a00..0c4e227 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs
@@ -76,14 +76,13 @@ namespace OpenSim.Region.ClientStack.Linden
76 76
77 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 77 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
78 private static Thread[] m_workerThreads = null; 78 private static Thread[] m_workerThreads = null;
79 79 private static int m_NumberScenes = 0;
80 private string m_Url = "localhost";
81
82 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue = 80 private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
83 new OpenMetaverse.BlockingQueue<aPollRequest>(); 81 new OpenMetaverse.BlockingQueue<aPollRequest>();
84 82
85 private Dictionary<UUID,PollServiceTextureEventArgs> m_pollservices = new Dictionary<UUID,PollServiceTextureEventArgs>(); 83 private Dictionary<UUID,PollServiceTextureEventArgs> m_pollservices = new Dictionary<UUID,PollServiceTextureEventArgs>();
86 84
85 private string m_Url = "localhost";
87 86
88 #region ISharedRegionModule Members 87 #region ISharedRegionModule Members
89 88
@@ -116,6 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden
116 m_scene.EventManager.OnRegisterCaps -= RegisterCaps; 115 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
117 m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; 116 m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
118 m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate; 117 m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate;
118 m_NumberScenes--;
119 m_scene = null; 119 m_scene = null;
120 } 120 }
121 121
@@ -128,6 +128,8 @@ namespace OpenSim.Region.ClientStack.Linden
128 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; 128 m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
129 m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; 129 m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate;
130 130
131 m_NumberScenes++;
132
131 if (m_workerThreads == null) 133 if (m_workerThreads == null)
132 { 134 {
133 m_workerThreads = new Thread[2]; 135 m_workerThreads = new Thread[2];
@@ -135,7 +137,7 @@ namespace OpenSim.Region.ClientStack.Linden
135 for (uint i = 0; i < 2; i++) 137 for (uint i = 0; i < 2; i++)
136 { 138 {
137 m_workerThreads[i] = WorkManager.StartThread(DoTextureRequests, 139 m_workerThreads[i] = WorkManager.StartThread(DoTextureRequests,
138 String.Format("TextureWorkerThread{0}", i), 140 String.Format("GetTextureWorker{0}", i),
139 ThreadPriority.Normal, 141 ThreadPriority.Normal,
140 false, 142 false,
141 false, 143 false,
@@ -165,17 +167,6 @@ namespace OpenSim.Region.ClientStack.Linden
165 adjData = pthrottles; 167 adjData = pthrottles;
166 } 168 }
167 169
168 // 0.125f converts from bits to bytes
169 //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
170 //pos += 4;
171 // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
172 //pos += 4;
173 // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
174 // pos += 4;
175 // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
176 // pos += 4;
177 // int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
178 // pos += 4;
179 pos = pos + 20; 170 pos = pos + 20;
180 int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4; 171 int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4;
181 //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); 172 //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
@@ -199,7 +190,18 @@ namespace OpenSim.Region.ClientStack.Linden
199 { 190 {
200 } 191 }
201 192
202 public void Close() { } 193 public void Close()
194 {
195 if(m_NumberScenes <= 0 && m_workerThreads != null)
196 {
197 m_log.DebugFormat("[GetTextureModule] Closing");
198
199 foreach (Thread t in m_workerThreads)
200 Watchdog.AbortThread(t.ManagedThreadId);
201
202 m_queue.Clear();
203 }
204 }
203 205
204 public string Name { get { return "GetTextureModule"; } } 206 public string Name { get { return "GetTextureModule"; } }
205 207
@@ -210,13 +212,6 @@ namespace OpenSim.Region.ClientStack.Linden
210 212
211 #endregion 213 #endregion
212 214
213 ~GetTextureModule()
214 {
215 foreach (Thread t in m_workerThreads)
216 Watchdog.AbortThread(t.ManagedThreadId);
217
218 }
219
220 private class PollServiceTextureEventArgs : PollServiceEventArgs 215 private class PollServiceTextureEventArgs : PollServiceEventArgs
221 { 216 {
222 private List<Hashtable> requests = 217 private List<Hashtable> requests =
@@ -306,11 +301,13 @@ namespace OpenSim.Region.ClientStack.Linden
306 301
307 UUID requestID = requestinfo.reqID; 302 UUID requestID = requestinfo.reqID;
308 303
304 if(m_scene.ShuttingDown)
305 return;
306
309 if (requestinfo.send503) 307 if (requestinfo.send503)
310 { 308 {
311 response = new Hashtable(); 309 response = new Hashtable();
312 310
313
314 response["int_response_code"] = 503; 311 response["int_response_code"] = 503;
315 response["str_response_string"] = "Throttled"; 312 response["str_response_string"] = "Throttled";
316 response["content_type"] = "text/plain"; 313 response["content_type"] = "text/plain";
@@ -412,15 +409,16 @@ namespace OpenSim.Region.ClientStack.Linden
412 } 409 }
413 } 410 }
414 411
415 private void DoTextureRequests() 412 private static void DoTextureRequests()
416 { 413 {
417 while (true) 414 while (true)
418 { 415 {
419 aPollRequest poolreq = m_queue.Dequeue(); 416 aPollRequest poolreq = m_queue.Dequeue();
420 417 Watchdog.UpdateThread();
421 poolreq.thepoll.Process(poolreq); 418 poolreq.thepoll.Process(poolreq);
422 } 419 }
423 } 420 }
421
424 internal sealed class CapsDataThrottler 422 internal sealed class CapsDataThrottler
425 { 423 {
426 424
@@ -498,7 +496,5 @@ namespace OpenSim.Region.ClientStack.Linden
498 } 496 }
499 public int ThrottleBytes; 497 public int ThrottleBytes;
500 } 498 }
501 } 499 }
502
503
504} 500}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index 61f4cd0..83f60c7 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -102,6 +102,8 @@ namespace OpenSim.Region.ClientStack.Linden
102 private static DoubleQueue<aPollRequest> m_queue = 102 private static DoubleQueue<aPollRequest> m_queue =
103 new DoubleQueue<aPollRequest>(); 103 new DoubleQueue<aPollRequest>();
104 104
105 private static int m_NumberScenes = 0;
106
105 #region ISharedRegionModule Members 107 #region ISharedRegionModule Members
106 108
107 public WebFetchInvDescModule() : this(true) {} 109 public WebFetchInvDescModule() : this(true) {}
@@ -145,17 +147,7 @@ namespace OpenSim.Region.ClientStack.Linden
145 StatsManager.DeregisterStat(s_processedRequestsStat); 147 StatsManager.DeregisterStat(s_processedRequestsStat);
146 StatsManager.DeregisterStat(s_queuedRequestsStat); 148 StatsManager.DeregisterStat(s_queuedRequestsStat);
147 149
148 if (ProcessQueuedRequestsAsync) 150 m_NumberScenes--;
149 {
150 if (m_workerThreads != null)
151 {
152 foreach (Thread t in m_workerThreads)
153 Watchdog.AbortThread(t.ManagedThreadId);
154
155 m_workerThreads = null;
156 }
157 }
158
159 Scene = null; 151 Scene = null;
160 } 152 }
161 153
@@ -203,6 +195,8 @@ namespace OpenSim.Region.ClientStack.Linden
203 195
204 Scene.EventManager.OnRegisterCaps += RegisterCaps; 196 Scene.EventManager.OnRegisterCaps += RegisterCaps;
205 197
198 m_NumberScenes++;
199
206 int nworkers = 2; // was 2 200 int nworkers = 2; // was 2
207 if (ProcessQueuedRequestsAsync && m_workerThreads == null) 201 if (ProcessQueuedRequestsAsync && m_workerThreads == null)
208 { 202 {
@@ -225,7 +219,23 @@ namespace OpenSim.Region.ClientStack.Linden
225 { 219 {
226 } 220 }
227 221
228 public void Close() { } 222 public void Close()
223 {
224 if (!m_Enabled)
225 return;
226
227 if (ProcessQueuedRequestsAsync)
228 {
229 if (m_NumberScenes <= 0 && m_workerThreads != null)
230 {
231 m_log.DebugFormat("[WebFetchInvDescModule] Closing");
232 foreach (Thread t in m_workerThreads)
233 Watchdog.AbortThread(t.ManagedThreadId);
234
235 m_workerThreads = null;
236 }
237 }
238 }
229 239
230 public string Name { get { return "WebFetchInvDescModule"; } } 240 public string Name { get { return "WebFetchInvDescModule"; } }
231 241
@@ -350,6 +360,9 @@ namespace OpenSim.Region.ClientStack.Linden
350 360
351 public void Process(aPollRequest requestinfo) 361 public void Process(aPollRequest requestinfo)
352 { 362 {
363 if(m_module == null || m_module.Scene == null || m_module.Scene.ShuttingDown)
364 return;
365
353 UUID requestID = requestinfo.reqID; 366 UUID requestID = requestinfo.reqID;
354 367
355 Hashtable response = new Hashtable(); 368 Hashtable response = new Hashtable();
@@ -425,31 +438,26 @@ namespace OpenSim.Region.ClientStack.Linden
425// } 438// }
426// } 439// }
427 440
428 private void DoInventoryRequests() 441 private static void DoInventoryRequests()
429 { 442 {
430 while (true) 443 while (true)
431 { 444 {
432 Watchdog.UpdateThread(); 445 Watchdog.UpdateThread();
433 446
434 WaitProcessQueuedInventoryRequest(); 447 aPollRequest poolreq = m_queue.Dequeue();
435 }
436 }
437 448
438 public void WaitProcessQueuedInventoryRequest() 449 if (poolreq != null && poolreq.thepoll != null)
439 {
440 aPollRequest poolreq = m_queue.Dequeue();
441
442 if (poolreq != null && poolreq.thepoll != null)
443 {
444 try
445 { 450 {
446 poolreq.thepoll.Process(poolreq); 451 try
447 } 452 {
448 catch (Exception e) 453 poolreq.thepoll.Process(poolreq);
449 { 454 }
450 m_log.ErrorFormat( 455 catch (Exception e)
451 "[INVENTORY]: Failed to process queued inventory request {0} for {1} in {2}. Exception {3}", 456 {
452 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", Scene.Name, e); 457 m_log.ErrorFormat(
458 "[INVENTORY]: Failed to process queued inventory request {0} for {1}. Exception {3}",
459 poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", e);
460 }
453 } 461 }
454 } 462 }
455 } 463 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 3971da0..2ef86c9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -556,6 +556,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
556 // In the future, we need to be able to do this programatically more predicably. 556 // In the future, we need to be able to do this programatically more predicably.
557 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 557 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
558 558
559 m_chatEvent.Reset();
559 scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); 560 scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
560 561
561 m_chatEvent.WaitOne(60000); 562 m_chatEvent.WaitOne(60000);
@@ -669,6 +670,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
669 // In the future, we need to be able to do this programatically more predicably. 670 // In the future, we need to be able to do this programatically more predicably.
670 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 671 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
671 672
673 m_chatEvent.Reset();
672 SceneObjectGroup rezzedSo 674 SceneObjectGroup rezzedSo
673 = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); 675 = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest));
674 676
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index fd6202a..ee0a4f8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
206 UUID fromID = UUID.Zero; 206 UUID fromID = UUID.Zero;
207 UUID ownerID = UUID.Zero; 207 UUID ownerID = UUID.Zero;
208 string message = c.Message; 208 string message = c.Message;
209 IScene scene = c.Scene; 209 Scene scene = c.Scene as Scene;
210 UUID destination = c.Destination; 210 UUID destination = c.Destination;
211 Vector3 fromPos = c.Position; 211 Vector3 fromPos = c.Position;
212 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); 212 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
@@ -217,47 +217,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
217 217
218 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; 218 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel;
219 219
220 if(!m_scenes.Contains(scene))
221 {
222 m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored",
223 scene.RegionInfo.RegionName);
224 return;
225 }
226
220 switch (sourceType) 227 switch (sourceType)
221 { 228 {
222 case ChatSourceType.Agent: 229 case ChatSourceType.Agent:
223 if (!(scene is Scene)) 230 ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
224 { 231 fromPos = avatar.AbsolutePosition;
225 m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}", 232 fromName = avatar.Name;
226 scene.RegionInfo.RegionName, c.Sender.AgentId); 233 fromID = c.Sender.AgentId;
227 return; 234 if (avatar.GodLevel >= 200)
228 } 235 { // let gods speak to outside or things may get confusing
229 ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); 236 fromNamePrefix = m_adminPrefix;
230 fromPos = avatar.AbsolutePosition; 237 checkParcelHide = false;
231 fromName = avatar.Name; 238 }
232 fromID = c.Sender.AgentId; 239 else
233 if (avatar.GodLevel >= 200) 240 {
234 { // let gods speak to outside or things may get confusing 241 checkParcelHide = true;
235 fromNamePrefix = m_adminPrefix; 242 }
236 checkParcelHide = false; 243 destination = UUID.Zero; // Avatars cant "SayTo"
237 } 244 ownerID = c.Sender.AgentId;
238 else
239 {
240 checkParcelHide = true;
241 }
242 destination = UUID.Zero; // Avatars cant "SayTo"
243 ownerID = c.Sender.AgentId;
244 245
245 hidePos = fromPos; 246 hidePos = fromPos;
246 break; 247 break;
247 248
248 case ChatSourceType.Object: 249 case ChatSourceType.Object:
249 fromID = c.SenderUUID; 250 fromID = c.SenderUUID;
250 251
251 if (c.SenderObject != null && c.SenderObject is SceneObjectPart) 252 if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
252 {
253 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
254 if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
255 { 253 {
256 checkParcelHide = true; 254 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
257 hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition; 255 if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
256 {
257 checkParcelHide = true;
258 hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
259 }
258 } 260 }
259 } 261 break;
260 break;
261 } 262 }
262 263
263 // TODO: iterate over message 264 // TODO: iterate over message
@@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
275 checkParcelHide = false; 276 checkParcelHide = false;
276 if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero) 277 if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
277 { 278 {
278 ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y); 279 ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y);
279 if (srcland != null && !srcland.LandData.SeeAVs) 280 if (srcland != null && !srcland.LandData.SeeAVs)
280 { 281 {
281 sourceParcelID = srcland.LandData.GlobalID; 282 sourceParcelID = srcland.LandData.GlobalID;
@@ -284,50 +285,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
284 } 285 }
285 } 286 }
286 287
287 foreach (Scene s in m_scenes) 288 scene.ForEachScenePresence(
288 { 289 delegate(ScenePresence presence)
289 // This should use ForEachClient, but clients don't have a position. 290 {
290 // If camera is moved into client, then camera position can be used 291 if (destination != UUID.Zero && presence.UUID != destination)
291 // MT: No, it can't, as chat is heard from the avatar position, not 292 return;
292 // the camera position.
293 293
294 s.ForEachScenePresence( 294 if(presence.IsChildAgent)
295 delegate(ScenePresence presence) 295 {
296 { 296 if(checkParcelHide)
297 if (destination != UUID.Zero && presence.UUID != destination) 297 return;
298 if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
299 ownerID, fromNamePrefix + fromName, c.Type,
300 message, sourceType, (destination != UUID.Zero)))
301 receiverIDs.Add(presence.UUID);
298 return; 302 return;
299 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); 303 }
300 if (Presencecheck != null) 304
305 ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
306 if (Presencecheck != null)
307 {
308 if (checkParcelHide)
301 { 309 {
302 // This will pass all chat from objects. Not 310 if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
303 // perfect, but it will do. For now. Better 311 return;
304 // than the prior behavior of muting all
305 // objects on a parcel with access restrictions
306 if (checkParcelHide)
307 {
308 if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
309 return;
310 }
311 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
312 {
313 if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
314 ownerID, fromNamePrefix + fromName, c.Type,
315 message, sourceType, (destination != UUID.Zero)))
316 receiverIDs.Add(presence.UUID);
317 }
318 } 312 }
319 else if(!checkParcelHide && (presence.IsChildAgent)) 313 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
320 { 314 {
321 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, 315 if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
322 ownerID, fromNamePrefix + fromName, c.Type, 316 ownerID, fromNamePrefix + fromName, c.Type,
323 message, sourceType, (destination != UUID.Zero))) 317 message, sourceType, (destination != UUID.Zero)))
324 receiverIDs.Add(presence.UUID); 318 receiverIDs.Add(presence.UUID);
325 } 319 }
326 } 320 }
327 ); 321 });
328 }
329 322
330 (scene as Scene).EventManager.TriggerOnChatToClients( 323 scene.EventManager.TriggerOnChatToClients(
331 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 324 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
332 } 325 }
333 326
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index ed93f05..9899ccd 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1049,6 +1049,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1049 1049
1050 sp.HasMovedAway(!(OutSideViewRange || logout)); 1050 sp.HasMovedAway(!(OutSideViewRange || logout));
1051 1051
1052 ulong sourceRegionHandle = sp.RegionHandle;
1053
1052 // Now let's make it officially a child agent 1054 // Now let's make it officially a child agent
1053 sp.MakeChildAgent(destinationHandle); 1055 sp.MakeChildAgent(destinationHandle);
1054 1056
@@ -1066,8 +1068,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1066 // This sleep can be increased if necessary. However, whilst it's active, 1068 // This sleep can be increased if necessary. However, whilst it's active,
1067 // an agent cannot teleport back to this region if it has teleported away. 1069 // an agent cannot teleport back to this region if it has teleported away.
1068 Thread.Sleep(2000); 1070 Thread.Sleep(2000);
1069 if (m_eqModule != null && !sp.DoNotCloseAfterTeleport) 1071// if (m_eqModule != null && !sp.DoNotCloseAfterTeleport)
1070 m_eqModule.DisableSimulator(sp.RegionHandle,sp.UUID); 1072// m_eqModule.DisableSimulator(sourceRegionHandle,sp.UUID);
1071 Thread.Sleep(500); 1073 Thread.Sleep(500);
1072 sp.Scene.CloseAgent(sp.UUID, false); 1074 sp.Scene.CloseAgent(sp.UUID, false);
1073 } 1075 }
@@ -1194,11 +1196,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1194 //HG hook 1196 //HG hook
1195 AgentHasMovedAway(sp, logout); 1197 AgentHasMovedAway(sp, logout);
1196 1198
1199 ulong sourceRegionHandle = sp.RegionHandle;
1200
1197 // Now let's make it officially a child agent 1201 // Now let's make it officially a child agent
1198 sp.MakeChildAgent(destinationHandle); 1202 sp.MakeChildAgent(destinationHandle);
1199 1203
1200
1201
1202 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 1204 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
1203 // go by HG hook 1205 // go by HG hook
1204 if (NeedsClosing(reg, OutSideViewRange)) 1206 if (NeedsClosing(reg, OutSideViewRange))
@@ -1213,10 +1215,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1213 // DECREASING THE WAIT TIME HERE WILL EITHER RESULT IN A VIEWER CRASH OR 1215 // DECREASING THE WAIT TIME HERE WILL EITHER RESULT IN A VIEWER CRASH OR
1214 // IN THE AVIE BEING PLACED IN INFINITY FOR A COUPLE OF SECONDS. 1216 // IN THE AVIE BEING PLACED IN INFINITY FOR A COUPLE OF SECONDS.
1215 1217
1216 Thread.Sleep(14000); 1218 Thread.Sleep(15000);
1217 if (m_eqModule != null && !sp.DoNotCloseAfterTeleport) 1219// if (m_eqModule != null && !sp.DoNotCloseAfterTeleport)
1218 m_eqModule.DisableSimulator(sp.RegionHandle,sp.UUID); 1220// m_eqModule.DisableSimulator(sourceRegionHandle,sp.UUID);
1219 Thread.Sleep(1000); 1221// Thread.Sleep(1000);
1220 1222
1221 // OK, it got this agent. Let's close everything 1223 // OK, it got this agent. Let's close everything
1222 // If we shouldn't close the agent due to some other region renewing the connection 1224 // If we shouldn't close the agent due to some other region renewing the connection
@@ -1802,6 +1804,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1802 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt. 1804 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt.
1803 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); 1805 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1804 1806
1807
1808
1809 agent.CloseChildAgents(false, neighbourRegion.RegionHandle, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
1810
1805 // this may need the attachments 1811 // this may need the attachments
1806 1812
1807 agent.HasMovedAway(true); 1813 agent.HasMovedAway(true);
@@ -1811,9 +1817,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1811 // FIXME: Possibly this should occur lower down after other commands to close other agents, 1817 // FIXME: Possibly this should occur lower down after other commands to close other agents,
1812 // but not sure yet what the side effects would be. 1818 // but not sure yet what the side effects would be.
1813 m_entityTransferStateMachine.ResetFromTransit(agent.UUID); 1819 m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
1814
1815 agent.CloseChildAgents(false, neighbourRegion.RegionHandle, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
1816
1817 // TODO: Check since what version this wasn't needed anymore. May be as old as 0.6 1820 // TODO: Check since what version this wasn't needed anymore. May be as old as 0.6
1818/* 1821/*
1819 // Backwards compatibility. Best effort 1822 // Backwards compatibility. Best effort
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 7d0c47f..e1764bf 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -182,6 +182,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
182// m_log.DebugFormat( 182// m_log.DebugFormat(
183// "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}", 183// "[USER MANAGEMENT MODULE]: Handling request for name binding of UUID {0} from {1}",
184// uuid, remote_client.Name); 184// uuid, remote_client.Name);
185 if(m_Scenes.Count <= 0)
186 return;
185 187
186 if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) 188 if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid))
187 { 189 {
@@ -288,6 +290,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
288 290
289 public List<UserData> GetUserData(string query, int page_size, int page_number) 291 public List<UserData> GetUserData(string query, int page_size, int page_number)
290 { 292 {
293 if(m_Scenes.Count <= 0)
294 return new List<UserData>();;
295
291 // search the user accounts service 296 // search the user accounts service
292 List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query); 297 List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query);
293 298
@@ -380,6 +385,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
380 /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param> 385 /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param>
381 private bool TryGetUserNamesFromServices(UUID uuid, string[] names) 386 private bool TryGetUserNamesFromServices(UUID uuid, string[] names)
382 { 387 {
388 if(m_Scenes.Count <= 0)
389 return false;
390
383 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid); 391 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid);
384 392
385 if (account != null) 393 if (account != null)
@@ -445,6 +453,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
445 453
446 public UUID GetUserIdByName(string firstName, string lastName) 454 public UUID GetUserIdByName(string firstName, string lastName)
447 { 455 {
456 if(m_Scenes.Count <= 0)
457 return UUID.Zero;
458
448 // TODO: Optimize for reverse lookup if this gets used by non-console commands. 459 // TODO: Optimize for reverse lookup if this gets used by non-console commands.
449 lock (m_UserCache) 460 lock (m_UserCache)
450 { 461 {
@@ -555,6 +566,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
555 #region Cache Management 566 #region Cache Management
556 public bool GetUser(UUID uuid, out UserData userdata) 567 public bool GetUser(UUID uuid, out UserData userdata)
557 { 568 {
569 if(m_Scenes.Count <= 0)
570 {
571 userdata = new UserData();
572 return false;
573 }
574
558 lock (m_UserCache) 575 lock (m_UserCache)
559 { 576 {
560 if (m_UserCache.TryGetValue(uuid, out userdata)) 577 if (m_UserCache.TryGetValue(uuid, out userdata))
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index ef0eec5..f40541e 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
94 if (config == null) 94 if (config == null)
95 return; 95 return;
96 96
97 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime", "60")); 97 int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime"));
98 if (refreshminutes < 0) 98 if (refreshminutes < 0)
99 { 99 {
100 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled."); 100 m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled.");
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index cdc605b..ca94f42 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
112 float rotation = 0f; 112 float rotation = 0f;
113 Vector3 rotationCenter = new Vector3(Scene.RegionInfo.RegionSizeX / 2f, Scene.RegionInfo.RegionSizeY / 2f, 0); 113 Vector3 rotationCenter = new Vector3(Scene.RegionInfo.RegionSizeX / 2f, Scene.RegionInfo.RegionSizeY / 2f, 0);
114 Vector3 boundingOrigin = new Vector3(0f, 0f, 0f); 114 Vector3 boundingOrigin = new Vector3(0f, 0f, 0f);
115 Vector3 boundingSize = new Vector3(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY, Constants.RegionHeight); 115 Vector3 boundingSize = new Vector3(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY, float.MaxValue);
116 bool debug = false; 116 bool debug = false;
117 117
118 OptionSet options = new OptionSet(); 118 OptionSet options = new OptionSet();
@@ -183,7 +183,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
183 { 183 {
184 try 184 try
185 { 185 {
186 boundingSize = v == null ? new Vector3(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY, Constants.RegionHeight) : Vector3.Parse(v); 186 boundingSize = v == null ? new Vector3(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY, float.MaxValue) : Vector3.Parse(v);
187 } 187 }
188 catch 188 catch
189 { 189 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 55c4fda..8bdf39a 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -174,6 +174,13 @@ namespace OpenSim.Region.Framework.Scenes
174 174
175 public SynchronizeSceneHandler SynchronizeScene; 175 public SynchronizeSceneHandler SynchronizeScene;
176 176
177 public bool ClampNegativeZ
178 {
179 get { return m_clampNegativeZ; }
180 }
181
182 private bool m_clampNegativeZ = false;
183
177 /// <summary> 184 /// <summary>
178 /// Used to prevent simultaneous calls to code that adds and removes agents. 185 /// Used to prevent simultaneous calls to code that adds and removes agents.
179 /// </summary> 186 /// </summary>
@@ -524,11 +531,11 @@ namespace OpenSim.Region.Framework.Scenes
524// private int m_lastUpdate; 531// private int m_lastUpdate;
525 private bool m_firstHeartbeat = true; 532 private bool m_firstHeartbeat = true;
526 533
527 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 534// private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
528 private bool m_reprioritizationEnabled = true; 535// private bool m_reprioritizationEnabled = true;
529 private double m_reprioritizationInterval = 5000.0; 536// private double m_reprioritizationInterval = 5000.0;
530 private double m_rootReprioritizationDistance = 10.0; 537// private double m_rootReprioritizationDistance = 10.0;
531 private double m_childReprioritizationDistance = 20.0; 538// private double m_childReprioritizationDistance = 20.0;
532 539
533 540
534 private Timer m_mapGenerationTimer = new Timer(); 541 private Timer m_mapGenerationTimer = new Timer();
@@ -1029,6 +1036,8 @@ namespace OpenSim.Region.Framework.Scenes
1029 m_clampPrimSize = true; 1036 m_clampPrimSize = true;
1030 } 1037 }
1031 1038
1039 m_clampNegativeZ = startupConfig.GetBoolean("ClampNegativeZ", m_clampNegativeZ);
1040
1032 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); 1041 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
1033 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 1042 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
1034 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 1043 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
@@ -1472,11 +1481,14 @@ namespace OpenSim.Region.Framework.Scenes
1472 1481
1473 m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); 1482 m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName);
1474 1483
1475 StatsReporter.Close();
1476 1484
1485 StatsReporter.Close();
1477 m_restartTimer.Stop(); 1486 m_restartTimer.Stop();
1478 m_restartTimer.Close(); 1487 m_restartTimer.Close();
1479 1488
1489 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
1490 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
1491
1480 // Kick all ROOT agents with the message, 'The simulator is going down' 1492 // Kick all ROOT agents with the message, 'The simulator is going down'
1481 ForEachScenePresence(delegate(ScenePresence avatar) 1493 ForEachScenePresence(delegate(ScenePresence avatar)
1482 { 1494 {
@@ -1503,13 +1515,10 @@ namespace OpenSim.Region.Framework.Scenes
1503 EventManager.TriggerSceneShuttingDown(this); 1515 EventManager.TriggerSceneShuttingDown(this);
1504 1516
1505 m_log.Debug("[SCENE]: Persisting changed objects"); 1517 m_log.Debug("[SCENE]: Persisting changed objects");
1518 Backup(true);
1506 1519
1507 Backup(false);
1508 m_sceneGraph.Close(); 1520 m_sceneGraph.Close();
1509 1521
1510 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
1511 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
1512
1513 base.Close(); 1522 base.Close();
1514 1523
1515 // XEngine currently listens to the EventManager.OnShutdown event to trigger script stop and persistence. 1524 // XEngine currently listens to the EventManager.OnShutdown event to trigger script stop and persistence.
@@ -1619,6 +1628,8 @@ namespace OpenSim.Region.Framework.Scenes
1619 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true; 1628 Watchdog.GetCurrentThreadInfo().AlarmIfTimeout = true;
1620 m_lastFrameTick = Util.EnvironmentTickCount(); 1629 m_lastFrameTick = Util.EnvironmentTickCount();
1621 Update(-1); 1630 Update(-1);
1631
1632 Watchdog.RemoveThread();
1622 } 1633 }
1623 1634
1624 private void Maintenance() 1635 private void Maintenance()
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 9308500..2ecb55b 100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -296,13 +296,15 @@ namespace OpenSim.Region.Framework.Scenes
296 Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, 296 Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X,
297 sceneObject.RootPart.GroupPosition.Y, 297 sceneObject.RootPart.GroupPosition.Y,
298 sceneObject.RootPart.GroupPosition.Z); 298 sceneObject.RootPart.GroupPosition.Z);
299 if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || 299 bool clampZ = m_parentScene.ClampNegativeZ;
300
301 if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || (npos.Z < 0.0 && clampZ) ||
300 npos.X > regionSizeX || 302 npos.X > regionSizeX ||
301 npos.Y > regionSizeY)) 303 npos.Y > regionSizeY))
302 { 304 {
303 if (npos.X < 0.0) npos.X = 1.0f; 305 if (npos.X < 0.0) npos.X = 1.0f;
304 if (npos.Y < 0.0) npos.Y = 1.0f; 306 if (npos.Y < 0.0) npos.Y = 1.0f;
305 if (npos.Z < 0.0) npos.Z = 0.0f; 307 if (npos.Z < 0.0 && clampZ) npos.Z = 0.0f;
306 if (npos.X > regionSizeX) npos.X = regionSizeX - 1.0f; 308 if (npos.X > regionSizeX) npos.X = regionSizeX - 1.0f;
307 if (npos.Y > regionSizeY) npos.Y = regionSizeY - 1.0f; 309 if (npos.Y > regionSizeY) npos.Y = regionSizeY - 1.0f;
308 310
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5903274..0d2c8c3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -4143,8 +4143,8 @@ namespace OpenSim.Region.Framework.Scenes
4143 { 4143 {
4144 byebyeRegions.Add(handle); 4144 byebyeRegions.Add(handle);
4145 // this should not be here 4145 // this should not be here
4146 if(eventQueue != null) 4146// if(eventQueue != null)
4147 eventQueue.DisableSimulator(handle,UUID); 4147/// eventQueue.DisableSimulator(handle,UUID);
4148 } 4148 }
4149 } 4149 }
4150 else 4150 else
@@ -4154,8 +4154,8 @@ namespace OpenSim.Region.Framework.Scenes
4154 { 4154 {
4155 byebyeRegions.Add(handle); 4155 byebyeRegions.Add(handle);
4156 // this should not be here 4156 // this should not be here
4157 if(eventQueue != null) 4157// if(eventQueue != null)
4158 eventQueue.DisableSimulator(handle,UUID); 4158// eventQueue.DisableSimulator(handle,UUID);
4159 } 4159 }
4160 } 4160 }
4161 } 4161 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs
index 9037277..c977285 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineCrossingTests.cs
@@ -196,6 +196,7 @@ default
196 196
197 EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det); 197 EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det);
198 198
199 Thread.Sleep(250); // wait for other change messages to pass
199 messageReceived = null; 200 messageReceived = null;
200 chatEventB.Reset(); 201 chatEventB.Reset();
201 xEngineB.PostObjectEvent(soSceneB.LocalId, ep); 202 xEngineB.PostObjectEvent(soSceneB.LocalId, ep);