diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 4088d4a44..6f07b5482 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -104,6 +104,11 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap // the moment it happens... therefore make a copy here. char const* volatile name = threadp->mName.c_str(); + // Always make sure that sRunning <= number of threads with status RUNNING, + // so do this before changing mStatus (meaning that once we see that we + // are STOPPED, then sRunning is also up to date). + --sRunning; + // We're done with the run function, this thread is done executing now. threadp->mStatus = STOPPED;