diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Monitoring/JobEngine.cs | 7 | ||||
-rw-r--r-- | OpenSim/Framework/Monitoring/Watchdog.cs | 13 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 38 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 59 |
4 files changed, 76 insertions, 41 deletions
diff --git a/OpenSim/Framework/Monitoring/JobEngine.cs b/OpenSim/Framework/Monitoring/JobEngine.cs index 0a39e4b..a6a059d 100644 --- a/OpenSim/Framework/Monitoring/JobEngine.cs +++ b/OpenSim/Framework/Monitoring/JobEngine.cs | |||
@@ -136,12 +136,15 @@ namespace OpenSim.Framework.Monitoring | |||
136 | if(m_jobQueue.Count <= 0) | 136 | if(m_jobQueue.Count <= 0) |
137 | m_cancelSource.Cancel(); | 137 | m_cancelSource.Cancel(); |
138 | 138 | ||
139 | if(m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop)) | 139 | m_finishedProcessingAfterStop.WaitOne(RequestProcessTimeoutOnStop); |
140 | m_finishedProcessingAfterStop.Close(); | 140 | m_finishedProcessingAfterStop.Close(); |
141 | } | 141 | } |
142 | finally | 142 | finally |
143 | { | 143 | { |
144 | m_cancelSource.Dispose(); | 144 | if(m_cancelSource != null) |
145 | m_cancelSource.Dispose(); | ||
146 | if(m_finishedProcessingAfterStop != null) | ||
147 | m_finishedProcessingAfterStop.Dispose(); | ||
145 | } | 148 | } |
146 | } | 149 | } |
147 | } | 150 | } |
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 8a4894e..5fb725c 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs | |||
@@ -193,7 +193,7 @@ namespace OpenSim.Framework.Monitoring | |||
193 | m_watchdogTimer.Dispose(); | 193 | m_watchdogTimer.Dispose(); |
194 | m_watchdogTimer = null; | 194 | m_watchdogTimer = null; |
195 | } | 195 | } |
196 | 196 | ||
197 | foreach(ThreadWatchdogInfo twi in m_threads.Values) | 197 | foreach(ThreadWatchdogInfo twi in m_threads.Values) |
198 | { | 198 | { |
199 | Thread t = twi.Thread; | 199 | Thread t = twi.Thread; |
@@ -341,6 +341,8 @@ namespace OpenSim.Framework.Monitoring | |||
341 | /// <param name="e"></param> | 341 | /// <param name="e"></param> |
342 | private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) | 342 | private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) |
343 | { | 343 | { |
344 | if(!m_enabled) | ||
345 | return; | ||
344 | int now = Environment.TickCount & Int32.MaxValue; | 346 | int now = Environment.TickCount & Int32.MaxValue; |
345 | int msElapsed = now - LastWatchdogThreadTick; | 347 | int msElapsed = now - LastWatchdogThreadTick; |
346 | 348 | ||
@@ -358,21 +360,26 @@ namespace OpenSim.Framework.Monitoring | |||
358 | List<ThreadWatchdogInfo> callbackInfos = null; | 360 | List<ThreadWatchdogInfo> callbackInfos = null; |
359 | List<ThreadWatchdogInfo> threadsToRemove = null; | 361 | List<ThreadWatchdogInfo> threadsToRemove = null; |
360 | 362 | ||
363 | const ThreadState thgone = ThreadState.Stopped | ThreadState.Aborted | ThreadState.AbortRequested; | ||
364 | |||
361 | lock (m_threads) | 365 | lock (m_threads) |
362 | { | 366 | { |
363 | foreach(ThreadWatchdogInfo threadInfo in m_threads.Values) | 367 | foreach(ThreadWatchdogInfo threadInfo in m_threads.Values) |
364 | { | 368 | { |
365 | if(threadInfo.Thread.ThreadState == ThreadState.Stopped) | 369 | if(!m_enabled) |
370 | return; | ||
371 | if(!threadInfo.Thread.IsAlive || (threadInfo.Thread.ThreadState & thgone) != 0) | ||
366 | { | 372 | { |
367 | if(threadsToRemove == null) | 373 | if(threadsToRemove == null) |
368 | threadsToRemove = new List<ThreadWatchdogInfo>(); | 374 | threadsToRemove = new List<ThreadWatchdogInfo>(); |
369 | 375 | ||
370 | threadsToRemove.Add(threadInfo); | 376 | threadsToRemove.Add(threadInfo); |
371 | 377 | /* | |
372 | if(callbackInfos == null) | 378 | if(callbackInfos == null) |
373 | callbackInfos = new List<ThreadWatchdogInfo>(); | 379 | callbackInfos = new List<ThreadWatchdogInfo>(); |
374 | 380 | ||
375 | callbackInfos.Add(threadInfo); | 381 | callbackInfos.Add(threadInfo); |
382 | */ | ||
376 | } | 383 | } |
377 | else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) | 384 | else if(!threadInfo.IsTimedOut && now - threadInfo.LastTick >= threadInfo.Timeout) |
378 | { | 385 | { |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 7de8c52..75ed999 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -420,6 +420,7 @@ namespace OpenSim.Framework | |||
420 | set { m_remotingPort = value; } | 420 | set { m_remotingPort = value; } |
421 | } | 421 | } |
422 | 422 | ||
423 | |||
423 | /// <value> | 424 | /// <value> |
424 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. | 425 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. |
425 | /// | 426 | /// |
@@ -427,42 +428,7 @@ namespace OpenSim.Framework | |||
427 | /// </value> | 428 | /// </value> |
428 | public IPEndPoint ExternalEndPoint | 429 | public IPEndPoint ExternalEndPoint |
429 | { | 430 | { |
430 | get | 431 | get { return Util.getEndPoint(m_externalHostName, m_internalEndPoint.Port); } |
431 | { | ||
432 | // Old one defaults to IPv6 | ||
433 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); | ||
434 | |||
435 | IPAddress ia = null; | ||
436 | // If it is already an IP, don't resolve it - just return directly | ||
437 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
438 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
439 | |||
440 | // Reset for next check | ||
441 | ia = null; | ||
442 | try | ||
443 | { | ||
444 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
445 | { | ||
446 | if (ia == null) | ||
447 | ia = Adr; | ||
448 | |||
449 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
450 | { | ||
451 | ia = Adr; | ||
452 | break; | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | catch (SocketException e) | ||
457 | { | ||
458 | throw new Exception( | ||
459 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
460 | e + "' attached to this exception", e); | ||
461 | } | ||
462 | |||
463 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
464 | } | ||
465 | |||
466 | set { m_externalHostName = value.ToString(); } | 432 | set { m_externalHostName = value.ToString(); } |
467 | } | 433 | } |
468 | 434 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 5eedd29..83d9df1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -429,6 +429,65 @@ namespace OpenSim.Framework | |||
429 | return regionCoord << 8; | 429 | return regionCoord << 8; |
430 | } | 430 | } |
431 | 431 | ||
432 | public static IPEndPoint getEndPoint(IPAddress ia, int port) | ||
433 | { | ||
434 | if(ia == null) | ||
435 | return null; | ||
436 | |||
437 | IPEndPoint newEP = null; | ||
438 | try | ||
439 | { | ||
440 | newEP = new IPEndPoint(ia, port); | ||
441 | } | ||
442 | catch | ||
443 | { | ||
444 | newEP = null; | ||
445 | } | ||
446 | return newEP; | ||
447 | } | ||
448 | |||
449 | public static IPEndPoint getEndPoint(string hostname, int port) | ||
450 | { | ||
451 | IPAddress ia = null; | ||
452 | // If it is already an IP, don't resolve it - just return directly | ||
453 | // we should not need this | ||
454 | if (IPAddress.TryParse(hostname, out ia)) | ||
455 | { | ||
456 | if (ia.Equals(IPAddress.Any) || ia.Equals(IPAddress.IPv6Any)) | ||
457 | return null; | ||
458 | return getEndPoint(ia, port); | ||
459 | } | ||
460 | |||
461 | // Reset for next check | ||
462 | ia = null; | ||
463 | try | ||
464 | { | ||
465 | foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) | ||
466 | { | ||
467 | if (ia == null) | ||
468 | ia = Adr; | ||
469 | |||
470 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
471 | { | ||
472 | ia = Adr; | ||
473 | break; | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | catch // (SocketException e) | ||
478 | { | ||
479 | /*throw new Exception( | ||
480 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
481 | e + "' attached to this exception", e);*/ | ||
482 | // Don't throw a fatal exception here, instead, return Null and handle it in the caller. | ||
483 | // Reason is, on systems such as OSgrid it has occured that known hostnames stop | ||
484 | // resolving and thus make surrounding regions crash out with this exception. | ||
485 | return null; | ||
486 | } | ||
487 | |||
488 | return getEndPoint(ia,port); | ||
489 | } | ||
490 | |||
432 | public static bool checkServiceURI(string uristr, out string serviceURI) | 491 | public static bool checkServiceURI(string uristr, out string serviceURI) |
433 | { | 492 | { |
434 | serviceURI = string.Empty; | 493 | serviceURI = string.Empty; |