Bugfixes for ExclusiveProxy Mode.

* changed PeerConnectStateBox::getNetState() to calcNetState() to provide up-to-date info (internal mNetState can be stale!)
 * Added "bool addrChangeLikely" parameter to ReleaseProxyExclusiveLock() - this parameter is determined by whether we actually started a UDP connection.
 * disabled ForceRestun in UdpStunner if addrChange is unlikely.
 * Reduced Stunner Period Slow from 3 minutes to 2 minutes - exact value will only be known after real-world testing.
 * More debugging.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4458 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-07-17 16:24:45 +00:00
parent 181ad06e33
commit c33b415ef4
7 changed files with 73 additions and 26 deletions

View file

@ -85,11 +85,6 @@ PeerConnectStateBox::PeerConnectStateBox()
}
uint32_t PeerConnectStateBox::getNetState()
{
return mNetState;
}
std::string NetStateAsString(uint32_t netstate)
{
@ -301,6 +296,13 @@ bool PeerConnectStateBox::shouldUseProxyPort(uint32_t netmode, uint32_t nathole,
return shouldUseProxyPortInternal(netstate);
}
uint32_t PeerConnectStateBox::calcNetState(uint32_t netmode, uint32_t nathole, uint32_t nattype)
{
uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype);
return netstate;
}
uint32_t PeerConnectStateBox::connectCb(uint32_t cbtype, uint32_t netmode, uint32_t nathole, uint32_t nattype)
{
uint32_t netstate = convertNetStateToInternal(netmode, nathole, nattype);

View file

@ -89,7 +89,7 @@ class PeerConnectStateBox
bool shouldUseProxyPort(uint32_t netmode, uint32_t nathole, uint32_t nattype);
uint32_t getNetState();
uint32_t calcNetState(uint32_t netmode, uint32_t nathole, uint32_t nattype);
std::string connectState() const;
std::string mPeerId;

View file

@ -232,8 +232,7 @@ void Feedback_ConnectionFailed(std::string pid);
void Feedback_ConnectionClosed(std::string pid);
void UdpConnectionFailed_locked(DhtPeerDetails *dpd);
void ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd);
void ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrChgLikely);
/***********************************************************************************************

View file

@ -708,9 +708,14 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
std::cerr << " UseProxyPort? " << proxyPort;
std::cerr << std::endl;
std::cerr << "dhtConnectionCallback: Checking ConnectLogic.NetState: ";
std::cerr << dpd->mConnectLogic.calcNetState(mNetMgr->getNetworkMode(), mNetMgr->getNatHoleMode(), mNetMgr->getNatTypeMode());
std::cerr << std::endl;
if (proxyPort)
{
exclusivePort = (CSB_NETSTATE_EXCLUSIVENAT == dpd->mConnectLogic.getNetState());
exclusivePort = (CSB_NETSTATE_EXCLUSIVENAT == dpd->mConnectLogic.calcNetState(
mNetMgr->getNetworkMode(), mNetMgr->getNatHoleMode(), mNetMgr->getNatTypeMode()));
}
if (exclusivePort)
@ -718,6 +723,11 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
std::cerr << "dhtConnectionCallback: we Require Exclusive Proxy Port for connection";
std::cerr << std::endl;
}
else
{
std::cerr << "dhtConnectionCallback: Dont need Exclusive Proxy Port for connection";
std::cerr << std::endl;
}
connectOk = true;
}
@ -777,7 +787,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
std::cerr << "PeerAction: Connect Proxy: ERROR Cannot find PeerStatus";
std::cerr << std::endl;
connectionAllowed = BITDHT_CONNECT_ERROR_TEMPUNAVAIL;
mProxyStunner->releaseExclusiveMode();
mProxyStunner->releaseExclusiveMode(false);
}
}
else
@ -915,7 +925,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
{
if (errcode)
{
ReleaseProxyExclusiveMode_locked(dpd);
ReleaseProxyExclusiveMode_locked(dpd, false);
dpd->mPeerReqStatusMsg = "STOPPED: ";
dpd->mPeerReqStatusMsg += decodeConnectionError(errcode);
@ -1134,9 +1144,19 @@ int p3BitDht::doActions()
proxyPort = dpd->mConnectLogic.getProxyPortChoice();
if (proxyPort)
{
std::cerr << "PeerAction: Using ProxyPort. NetState indicates Exclusive Mode";
std::cerr << "PeerAction: Using ProxyPort. Checking ConnectLogic.NetState: ";
std::cerr << dpd->mConnectLogic.calcNetState(mNetMgr->getNetworkMode(),
mNetMgr->getNatHoleMode(), mNetMgr->getNatTypeMode());
std::cerr << std::endl;
exclusivePort = (CSB_NETSTATE_EXCLUSIVENAT == dpd->mConnectLogic.getNetState());
exclusivePort = (CSB_NETSTATE_EXCLUSIVENAT == dpd->mConnectLogic.calcNetState(
mNetMgr->getNetworkMode(), mNetMgr->getNatHoleMode(), mNetMgr->getNatTypeMode()));
if (exclusivePort)
{
std::cerr << "PeerAction: NetState indicates Exclusive Mode";
std::cerr << std::endl;
}
}
}
else
@ -1271,7 +1291,7 @@ int p3BitDht::doActions()
if (grabbedExclusivePort)
{
mProxyStunner->releaseExclusiveMode();
mProxyStunner->releaseExclusiveMode(false);
}
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
@ -2008,7 +2028,7 @@ void p3BitDht::Feedback_Connected(std::string pid)
std::cerr << std::endl;
}
ReleaseProxyExclusiveMode_locked(dpd);
ReleaseProxyExclusiveMode_locked(dpd, true);
}
void p3BitDht::Feedback_ConnectionFailed(std::string pid)
@ -2110,12 +2130,12 @@ void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
std::cerr << std::endl;
}
ReleaseProxyExclusiveMode_locked(dpd);
ReleaseProxyExclusiveMode_locked(dpd, true);
}
void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd)
void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrChgLikely)
{
#ifdef DEBUG_BITDHT_COMMON
std::cerr << "p3BitDht::ReleaseProxyExclusiveMode_locked()";
@ -2125,7 +2145,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd)
if (dpd->mExclusiveProxyLock)
{
if (mProxyStunner->releaseExclusiveMode())
if (mProxyStunner->releaseExclusiveMode(addrChgLikely))
{
dpd->mExclusiveProxyLock = false;