mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
fix a couple of rare failures due to race conditions testing or
valgrind flushed out.
This commit is contained in:
parent
3db7fccb53
commit
175aace629
1 changed files with 11 additions and 4 deletions
|
@ -373,7 +373,6 @@ CRefMgr::getMakeCookieRef( const char* const connName, bool* isDead )
|
|||
}
|
||||
break;
|
||||
}
|
||||
assert( cinfo->GetRef() );
|
||||
return cinfo;
|
||||
}
|
||||
|
||||
|
@ -405,7 +404,15 @@ CRefMgr::PrintSocketInfo( int socket, string& out )
|
|||
CidInfo*
|
||||
CRefMgr::getCookieRef( CookieID cid )
|
||||
{
|
||||
return m_cidlock->Claim( cid );
|
||||
CidInfo* cinfo = NULL;
|
||||
for ( ; ; ) {
|
||||
cinfo = m_cidlock->Claim( cid );
|
||||
if ( NULL != cinfo->GetRef() ) {
|
||||
break;
|
||||
}
|
||||
m_cidlock->Relinquish( cinfo, true );
|
||||
}
|
||||
return cinfo;
|
||||
} /* getCookieRef */
|
||||
|
||||
CidInfo*
|
||||
|
@ -627,7 +634,7 @@ SafeCref::SafeCref( const char* connName, const char* cookie, HostID hid,
|
|||
}
|
||||
}
|
||||
|
||||
/* ConnName case -- must exist */
|
||||
/* ConnName case -- must exist (unless DB record's been removed */
|
||||
SafeCref::SafeCref( const char* const connName )
|
||||
: m_cinfo( NULL )
|
||||
, m_mgr( CRefMgr::Get() )
|
||||
|
@ -635,7 +642,7 @@ SafeCref::SafeCref( const char* const connName )
|
|||
{
|
||||
bool isDead = false;
|
||||
CidInfo* cinfo = m_mgr->getMakeCookieRef( connName, &isDead );
|
||||
if ( cinfo != NULL ) {
|
||||
if ( NULL != cinfo && NULL != cinfo->GetRef() ) {
|
||||
assert( cinfo->GetCid() == cinfo->GetRef()->GetCid() );
|
||||
m_locked = cinfo->GetRef()->Lock();
|
||||
m_cinfo = cinfo;
|
||||
|
|
Loading…
Reference in a new issue