Fixed deadlock between p3connmgr::mtx and libbitdht::mtx

* shifted dht stats call outside of p3connmgr's mtx.

NB: As Dht callback functions hold DHT lock, then lock p3ConnectMgr...
    we cannot have any opposite locks (p3connmgr, then DHT) or we have
    potential for a deadlock.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3861 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2010-11-23 19:32:19 +00:00
parent 6589b49025
commit d9847e2622

View File

@ -3912,11 +3912,18 @@ bool p3ConnectMgr::getDHTEnabled()
void p3ConnectMgr::getNetStatus(pqiNetStatus &status) void p3ConnectMgr::getNetStatus(pqiNetStatus &status)
{ {
/* cannot lock local stack, then call DHT... as this can cause lock up */
/* must extract data... then update mNetFlags */
bool dhtOk = netAssistConnectActive();
uint32_t netsize, rsnetsize;
netAssistConnectStats(netsize, rsnetsize);
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
/* quick update of the stuff that can change! */ /* quick update of the stuff that can change! */
mNetFlags.mDhtOk = netAssistConnectActive(); mNetFlags.mDhtOk = dhtOk;
netAssistConnectStats(mNetFlags.mDhtNetworkSize, mNetFlags.mDhtRsNetworkSize); netAssistConnectStats(netsize, rsnetsize);
status = mNetFlags; status = mNetFlags;
} }