removed deadlock by replacing lock() by trylock(). As a result sometimes, authGPG::getDetails() may return false. As soon as it is used by the GUI only, it shoul dbe ok.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1823 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-11-14 20:20:33 +00:00
parent 6a48284c31
commit e77064eaf1

View File

@ -1331,20 +1331,15 @@ void GPGAuthMgr::addTrustingPeer(std::string)
}
/**** These Two are common */
std::string GPGAuthMgr::getName(std::string id)
std::string GPGAuthMgr::getPGPName(std::string id)
{
std::string name = AuthSSL::getName(id);
if (name != "")
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id)))
{
return it->second.user.name;
}
}
return name;
return std::string();
}
bool GPGAuthMgr::getDetails(std::string id, pqiAuthDetails &details)
@ -1360,8 +1355,9 @@ bool GPGAuthMgr::getDetails(std::string id, pqiAuthDetails &details)
if (AuthSSL::getDetails(id, details))
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
if(pgpMtx.trylock())
{
certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(details.issuer)))
{
@ -1371,24 +1367,30 @@ bool GPGAuthMgr::getDetails(std::string id, pqiAuthDetails &details)
details.email = it->second.user.email;
//details = it->second.user;
}
pgpMtx.unlock() ;
return true;
}
return true;
return false ;
}
else
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
if(pgpMtx.trylock())
{
/* if we cannot find a ssl cert - might be a pgp cert */
certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id)))
{
/* what do we want from the gpg mgr */
details = it->second.user;
pgpMtx.unlock() ;
return true;
}
pgpMtx.unlock() ;
}
return false;
}
}