mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
corrected a cross lock between p3ConnectMgr::connectResult() ->...-> UdpBitDht::removeFindNode() and bdNodeManager::iteration() ->...-> p3ConnectMgr::retryConnectUDP(), by making calls to netAssisFriend() off-mutex.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3874 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
78dea3c630
commit
4f80b2557e
@ -73,6 +73,9 @@ const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4;
|
|||||||
* #define CONN_DEBUG_TICK 1
|
* #define CONN_DEBUG_TICK 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
#define CONN_DEBUG 1
|
||||||
|
#define CONN_DEBUG_RESET 1
|
||||||
|
#define CONN_DEBUG_TICK 1
|
||||||
#define CONN_DEBUG_RESET 1
|
#define CONN_DEBUG_RESET 1
|
||||||
|
|
||||||
/****
|
/****
|
||||||
@ -1736,6 +1739,9 @@ bool p3ConnectMgr::connectAttempt(std::string id, struct sockaddr_in &addr,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool p3ConnectMgr::connectResult(std::string id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address)
|
bool p3ConnectMgr::connectResult(std::string id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address)
|
||||||
|
{
|
||||||
|
bool should_netAssistFriend_false = false ;
|
||||||
|
bool should_netAssistFriend_true = false ;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
@ -1820,11 +1826,12 @@ bool p3ConnectMgr::connectResult(std::string id, bool success, uint32_t flags, s
|
|||||||
/* remove other attempts */
|
/* remove other attempts */
|
||||||
it->second.inConnAttempt = false;
|
it->second.inConnAttempt = false;
|
||||||
it->second.connAddrs.clear();
|
it->second.connAddrs.clear();
|
||||||
netAssistFriend(id, false);
|
should_netAssistFriend_false = true ;
|
||||||
mStatusChanged = true;
|
mStatusChanged = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
it->second.inConnAttempt = false;
|
it->second.inConnAttempt = false;
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
@ -1841,16 +1848,20 @@ bool p3ConnectMgr::connectResult(std::string id, bool success, uint32_t flags, s
|
|||||||
|
|
||||||
it->second.lastcontact = time(NULL); /* time of disconnect */
|
it->second.lastcontact = time(NULL); /* time of disconnect */
|
||||||
|
|
||||||
netAssistFriend(id, true);
|
should_netAssistFriend_true = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->second.connAddrs.size() < 1)
|
if (it->second.connAddrs.size() >= 1)
|
||||||
{
|
{
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
it->second.actions |= RS_PEER_CONNECT_REQ;
|
it->second.actions |= RS_PEER_CONNECT_REQ;
|
||||||
mStatusChanged = true;
|
mStatusChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(should_netAssistFriend_true)
|
||||||
|
netAssistFriend(id,true) ;
|
||||||
|
if(should_netAssistFriend_false)
|
||||||
|
netAssistFriend(id,false) ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2151,6 +2162,9 @@ void p3ConnectMgr::peerConnectRequest(std::string id, struct sockaddr_in radd
|
|||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
|
||||||
bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMode, uint32_t visState, time_t lastContact)
|
bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMode, uint32_t visState, time_t lastContact)
|
||||||
|
{
|
||||||
|
bool should_netAssistFriend_true = false ;
|
||||||
|
bool should_netAssistFriend_false = false ;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
@ -2224,18 +2238,17 @@ bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMod
|
|||||||
if (it->second.visState & RS_VIS_STATE_NODHT)
|
if (it->second.visState & RS_VIS_STATE_NODHT)
|
||||||
{
|
{
|
||||||
/* hidden from DHT world */
|
/* hidden from DHT world */
|
||||||
netAssistFriend(id, false);
|
should_netAssistFriend_false = true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
netAssistFriend(id, true);
|
should_netAssistFriend_true = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3ConnectMgr::addFriend() Creating New Entry" << std::endl;
|
std::cerr << "p3ConnectMgr::addFriend() Creating New Entry" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -2260,9 +2273,15 @@ bool p3ConnectMgr::addFriend(std::string id, std::string gpg_id, uint32_t netMod
|
|||||||
mStatusChanged = true;
|
mStatusChanged = true;
|
||||||
|
|
||||||
/* expect it to be a standard DHT */
|
/* expect it to be a standard DHT */
|
||||||
netAssistFriend(id, true);
|
should_netAssistFriend_true = true ;
|
||||||
|
|
||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(should_netAssistFriend_true)
|
||||||
|
netAssistFriend(id,true) ;
|
||||||
|
if(should_netAssistFriend_false)
|
||||||
|
netAssistFriend(id,false) ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3122,7 +3141,6 @@ bool p3ConnectMgr::setLocation(std::string id, std::string location)
|
|||||||
|
|
||||||
bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
|
bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||||
{
|
{
|
||||||
uint32_t netMode;
|
uint32_t netMode;
|
||||||
@ -3134,11 +3152,13 @@ bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dht_state ;
|
||||||
|
bool isFriend = false;
|
||||||
|
{
|
||||||
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
/* check if it is a friend */
|
/* check if it is a friend */
|
||||||
std::map<std::string, peerConnectState>::iterator it;
|
std::map<std::string, peerConnectState>::iterator it;
|
||||||
bool isFriend = false;
|
|
||||||
if (mFriendList.end() == (it = mFriendList.find(id)))
|
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||||
{
|
{
|
||||||
if (mOthersList.end() == (it = mOthersList.find(id)))
|
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||||
@ -3153,10 +3173,12 @@ bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
|
|||||||
|
|
||||||
/* "it" points to peer */
|
/* "it" points to peer */
|
||||||
it->second.visState = visState;
|
it->second.visState = visState;
|
||||||
|
dht_state = it->second.visState & RS_VIS_STATE_NODHT ;
|
||||||
|
}
|
||||||
if(isFriend)
|
if(isFriend)
|
||||||
{
|
{
|
||||||
/* toggle DHT state */
|
/* toggle DHT state */
|
||||||
if (it->second.visState & RS_VIS_STATE_NODHT)
|
if(dht_state)
|
||||||
{
|
{
|
||||||
/* hidden from DHT world */
|
/* hidden from DHT world */
|
||||||
netAssistFriend(id, false);
|
netAssistFriend(id, false);
|
||||||
@ -3859,17 +3881,25 @@ bool p3ConnectMgr::netAssistConnectShutdown()
|
|||||||
bool p3ConnectMgr::netAssistFriend(std::string id, bool on)
|
bool p3ConnectMgr::netAssistFriend(std::string id, bool on)
|
||||||
{
|
{
|
||||||
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
std::map<uint32_t, pqiNetAssistConnect *>::iterator it;
|
||||||
|
std::list<pqiNetAssistConnect*> toFind ;
|
||||||
|
std::list<pqiNetAssistConnect*> toDrop ;
|
||||||
|
|
||||||
|
{
|
||||||
|
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
|
||||||
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
for(it = mDhts.begin(); it != mDhts.end(); it++)
|
||||||
{
|
{
|
||||||
if (on)
|
if (on)
|
||||||
{
|
toFind.push_back(it->second) ;
|
||||||
(it->second)->findPeer(id);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
toDrop.push_back(it->second) ;
|
||||||
(it->second)->dropPeer(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(std::list<pqiNetAssistConnect*>::const_iterator it(toFind.begin());it!=toFind.end();++it)
|
||||||
|
(*it)->findPeer(id) ;
|
||||||
|
for(std::list<pqiNetAssistConnect*>::const_iterator it(toDrop.begin());it!=toDrop.end();++it)
|
||||||
|
(*it)->dropPeer(id) ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user