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
This commit is contained in:
Justin Clark-Casey (justincc)
2015-02-25 20:01:34 +00:00
parent 8333dcf388
commit 686b22da6e

View File

@@ -161,7 +161,6 @@ namespace OpenSim.Framework.Monitoring
finally
{
m_cancelSource.Dispose();
m_jobQueue = null;
}
}
}
@@ -250,7 +249,19 @@ namespace OpenSim.Framework.Monitoring
{
while (IsRunning || m_jobQueue.Count > 0)
{
CurrentJob = m_jobQueue.Take(m_cancelSource.Token);
try
{
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)
m_log.DebugFormat("[{0}]: Processing job {1}", LoggingName, CurrentJob.Name);