On shutdown (job engine stop), don't allow the ObjectDisposedException on BlockingCollection.Take() to propogate if the running thread checked IsRunning before the stop thread set it and disposed of the canellation source.

Looks to address http://opensimulator.org/mantis/view.php?id=7453
inv-download
Justin Clark-Casey (justincc) 2015-02-25 20:01:34 +00:00
parent 8333dcf388
commit 686b22da6e
1 changed files with 13 additions and 2 deletions

View File

@ -161,7 +161,6 @@ namespace OpenSim.Framework.Monitoring
finally finally
{ {
m_cancelSource.Dispose(); m_cancelSource.Dispose();
m_jobQueue = null;
} }
} }
} }
@ -249,8 +248,20 @@ namespace OpenSim.Framework.Monitoring
try try
{ {
while (IsRunning || m_jobQueue.Count > 0) while (IsRunning || m_jobQueue.Count > 0)
{
try
{ {
CurrentJob = m_jobQueue.Take(m_cancelSource.Token); CurrentJob = m_jobQueue.Take(m_cancelSource.Token);
}
catch (ObjectDisposedException e)
{
// If we see this whilst not running then it may be due to a race where this thread checks
// IsRunning after the stopping thread sets it to false and disposes of the cancellation source.
if (IsRunning)
throw e;
else
break;
}
if (LogLevel >= 1) if (LogLevel >= 1)
m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name); m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name);