added missing mutex, and warnings if permission flags methods are not called with correct ids

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6287 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-04-03 22:50:50 +00:00
parent c2512318a3
commit 8399ce82ee
3 changed files with 29 additions and 8 deletions

View File

@ -1813,26 +1813,47 @@ bool p3PeerMgrIMPL::assignPeersToGroup(const std::string &groupId, const std::li
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags_sslid(const std::string& ssl_id)
{
std::string gpg_id ;
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
if(ssl_id.length() != 32)
{
std::cerr << "(EE) p3PeerMgrIMPL::servicePermissionFlags_sslid() called with inconsistent id " << ssl_id << std::endl;
return RS_SERVICE_PERM_ALL ;
}
std::map<std::string, peerState>::const_iterator it = mFriendList.find(ssl_id);
if(it == mFriendList.end())
return RS_SERVICE_PERM_ALL ;
else
return servicePermissionFlags(it->second.gpg_id) ;
if(it == mFriendList.end())
return RS_SERVICE_PERM_ALL ;
gpg_id = it->second.gpg_id ;
}
return servicePermissionFlags(gpg_id) ;
}
ServicePermissionFlags p3PeerMgrIMPL::servicePermissionFlags(const std::string& pgp_id)
{
//
//
if(pgp_id.length() != 16)
{
std::cerr << "(EE) p3PeerMgrIMPL::servicePermissionFlags() called with inconsistent id " << pgp_id << std::endl;
return RS_SERVICE_PERM_ALL ;
}
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::map<std::string,ServicePermissionFlags>::const_iterator it = mFriendsPermissionFlags.find( pgp_id ) ;
if(it == mFriendsPermissionFlags.end())
return RS_SERVICE_PERM_ALL ;
else
return it->second ;
}
}
void p3PeerMgrIMPL::setServicePermissionFlags(const std::string& pgp_id, const ServicePermissionFlags& flags)
{

View File

@ -123,7 +123,7 @@ class p3PeerMgr
virtual ~p3PeerMgr() { return; }
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0,ServicePermissionFlags = RS_SERVICE_PERM_ALL) = 0;
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL)) = 0;
virtual bool removeFriend(const std::string &ssl_id) = 0;
virtual bool isFriend(const std::string &ssl_id) = 0;
@ -214,7 +214,7 @@ class p3PeerMgrIMPL: public p3PeerMgr, public p3Config
/************************************************************************************************/
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id, uint32_t netMode = RS_NET_MODE_UDP,
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0,ServicePermissionFlags = RS_SERVICE_PERM_ALL);
uint32_t visState = RS_VIS_STATE_STD , time_t lastContact = 0,ServicePermissionFlags = ServicePermissionFlags(RS_SERVICE_PERM_ALL));
virtual bool removeFriend(const std::string &ssl_id);
virtual bool isFriend(const std::string &ssl_id);

View File

@ -707,7 +707,7 @@ void p3disc::recvPeerDetails(RsDiscReply *item, const std::string &certGpgId)
#ifdef P3DISC_DEBUG
std::cerr << "--> Adding to friends list " << pit->pid << " - " << pit->gpg_id << std::endl;
#endif
mPeerMgr->addFriend(pit->pid, pit->gpg_id, pit->netMode, RS_VIS_STATE_NODISC, 0);
mPeerMgr->addFriend(pit->pid, pit->gpg_id, pit->netMode, RS_VIS_STATE_NODISC,(time_t)0,RS_SERVICE_PERM_ALL);
}
}