removing nsAutoLock workaround for bug 221331.

This commit is contained in:
darin%meer.net 2003-10-08 03:38:46 +00:00
Родитель 7a85e4d69a
Коммит 5b691ee334
1 изменённых файлов: 32 добавлений и 35 удалений

Просмотреть файл

@ -234,46 +234,43 @@ nsIOThreadPool::ThreadFunc(void *arg)
LOG(("entering ThreadFunc\n")); LOG(("entering ThreadFunc\n"));
// XXX not using a nsAutoLock here because we need to temporarily unlock {
// and relock in the inner loop. nsAutoLock has a bug, causing it to warn nsAutoLock lock(pool->mLock);
// of a bogus deadlock, which makes us avoid it here. (see bug 221331)
PR_Lock(pool->mLock);
for (;;) { for (;;) {
// never wait if we are shutting down; always process queued events... // never wait if we are shutting down; always process queued events...
if (PR_CLIST_IS_EMPTY(&pool->mEventQ) && !pool->mShutdown) { if (PR_CLIST_IS_EMPTY(&pool->mEventQ) && !pool->mShutdown) {
pool->mNumIdleThreads++; pool->mNumIdleThreads++;
PR_WaitCondVar(pool->mCV, THREAD_IDLE_TIMEOUT); PR_WaitCondVar(pool->mCV, THREAD_IDLE_TIMEOUT);
pool->mNumIdleThreads--; pool->mNumIdleThreads--;
}
// if the queue is still empty, then kill this thread...
if (PR_CLIST_IS_EMPTY(&pool->mEventQ))
break;
// handle one event at a time: we don't want this one thread to hog
// all the events while other threads may be able to help out ;-)
do {
PLEvent *event = PLEVENT_FROM_LINK(PR_LIST_HEAD(&pool->mEventQ));
PR_REMOVE_AND_INIT_LINK(&event->link);
LOG(("event:%p\n", event));
// release lock!
lock.unlock();
PL_HandleEvent(event);
lock.lock();
}
while (!PR_CLIST_IS_EMPTY(&pool->mEventQ));
} }
// if the queue is still empty, then kill this thread... // thread is dying... cleanup mThreads, unless of course if we are
if (PR_CLIST_IS_EMPTY(&pool->mEventQ)) // shutting down, in which case Shutdown will clean up mThreads for us.
break; if (!pool->mShutdown)
pool->mThreads[pool->GetCurrentThreadIndex()] = nsnull;
// handle one event at a time: we don't want this one thread to hog
// all the events while other threads may be able to help out ;-)
do {
PLEvent *event = PLEVENT_FROM_LINK(PR_LIST_HEAD(&pool->mEventQ));
PR_REMOVE_AND_INIT_LINK(&event->link);
LOG(("event:%p\n", event));
// release lock!
PR_Unlock(pool->mLock);
PL_HandleEvent(event);
PR_Lock(pool->mLock);
}
while (!PR_CLIST_IS_EMPTY(&pool->mEventQ));
} }
// thread is dying... cleanup mThreads, unless of course if we are
// shutting down, in which case Shutdown will clean up mThreads for us.
if (!pool->mShutdown)
pool->mThreads[pool->GetCurrentThreadIndex()] = nsnull;
PR_Unlock(pool->mLock);
// release our reference to the pool // release our reference to the pool
NS_RELEASE(pool); NS_RELEASE(pool);