aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorDiva Canto2015-11-27 08:24:39 -0800
committerDiva Canto2015-11-27 08:24:39 -0800
commitcade717b5ffd0445c6246a55da5e80da2562450d (patch)
tree4e0a182d64905d35524336ee93b1283385494447 /OpenSim/Framework
parentSometimes the viewer sends a null string as mapName; this made the client thr... (diff)
parentadd a delay to consume other change messages on move and cross (diff)
downloadopensim-SC_OLD-cade717b5ffd0445c6246a55da5e80da2562450d.zip
opensim-SC_OLD-cade717b5ffd0445c6246a55da5e80da2562450d.tar.gz
opensim-SC_OLD-cade717b5ffd0445c6246a55da5e80da2562450d.tar.bz2
opensim-SC_OLD-cade717b5ffd0445c6246a55da5e80da2562450d.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework')
-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
4 files changed, 70 insertions, 82 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;