fix deadlock by collecting crefs into local storage before starting to

act on them.
This commit is contained in:
ehouse 2005-09-04 20:36:53 +00:00
parent 7803fead80
commit 0134c96962

View file

@ -314,15 +314,24 @@ CRefMgr::getCookieRef_impl( CookieID cookieID )
void void
CRefMgr::CheckHeartbeats( time_t now ) CRefMgr::CheckHeartbeats( time_t now )
{
vector<CookieRef*> crefs;
{ {
RWReadLock rwl( &m_cookieMapRWLock ); RWReadLock rwl( &m_cookieMapRWLock );
CookieMap::iterator iter = m_cookieMap.begin(); CookieMap::iterator iter = m_cookieMap.begin();
while ( iter != m_cookieMap.end() ) { while ( iter != m_cookieMap.end() ) {
SafeCref scr( iter->second ); crefs.push_back(iter->second);
++iter;
}
}
unsigned int i;
for ( i = 0; i < crefs.size(); ++i ) {
SafeCref scr( crefs[i] );
if ( scr.IsValid() ) { if ( scr.IsValid() ) {
scr.CheckHeartbeats( now ); scr.CheckHeartbeats( now );
} }
++iter;
} }
} /* CheckHeartbeats */ } /* CheckHeartbeats */