mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 11:00:14 -05:00
More Udp Connection Bugfixes:
* connected Dht ConnectCallback() * added missing break statement in peernet logic (directattempt). * added state update if ConnectionRequest is rejected by DHT (normally because MODE UNAVAILABLE). * switched off UdpStunner. * added Debug Modes to rsUdpStack & rsFixedUdpStack. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4448 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0229ef1fe8
commit
bffaf6e5ef
@ -375,7 +375,7 @@ uint32_t PeerConnectStateBox::connectCb_direct()
|
||||
}
|
||||
else if (mNoAttempts >= MAX_DIRECT_ATTEMPTS) /* if too many attempts */
|
||||
{
|
||||
/* switch to RELAY attempt */
|
||||
/* no RELAY attempt => FAILED_WAIT */
|
||||
mState = CSB_FAILED_WAIT;
|
||||
retval = CSB_ACTION_WAIT;
|
||||
mStateTS = now;
|
||||
|
@ -67,7 +67,7 @@ virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t statu
|
||||
virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
|
||||
uint32_t mode, uint32_t point, uint32_t cbtype, uint32_t errcode)
|
||||
{
|
||||
return 0;
|
||||
return mParent->ConnectCallback(srcId, proxyId, destId, mode, point, cbtype, errcode);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -329,6 +329,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t status, DhtPeer
|
||||
connectOk = false;
|
||||
doTCPCallback = true;
|
||||
}
|
||||
break;
|
||||
case CSB_ACTION_DIRECT_CONN:
|
||||
{
|
||||
|
||||
@ -421,6 +422,9 @@ int p3BitDht::UnreachablePeerCallback_locked(const bdId *id, uint32_t status, Dh
|
||||
default:
|
||||
case CSB_ACTION_WAIT:
|
||||
{
|
||||
std::cerr << "dhtPeerCallback. Request to Wait ... so no Connection Attempt for ";
|
||||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
connectOk = false;
|
||||
}
|
||||
break;
|
||||
@ -475,7 +479,7 @@ int p3BitDht::UnreachablePeerCallback_locked(const bdId *id, uint32_t status, Dh
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "dhtPeerCallback. Cancelled Connection Attempt for";
|
||||
std::cerr << "dhtPeerCallback. Cancelled Connection Attempt for ";
|
||||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
@ -1023,6 +1027,7 @@ int p3BitDht::doActions()
|
||||
std::cerr << std::endl;
|
||||
|
||||
bool connectionRequested = false;
|
||||
bool connectionReqFailed = false;
|
||||
|
||||
if ((action.mMode == BITDHT_CONNECT_MODE_DIRECT) ||
|
||||
(action.mMode == BITDHT_CONNECT_MODE_RELAY))
|
||||
@ -1030,8 +1035,14 @@ int p3BitDht::doActions()
|
||||
struct sockaddr_in laddr; // We zero this address. The DHT layer should be able to handle this!
|
||||
sockaddr_clear(&laddr);
|
||||
uint32_t start = 1;
|
||||
mUdpBitDht->ConnectionRequest(&laddr, &(action.mDestId.id), action.mMode, start);
|
||||
connectionRequested = true;
|
||||
if (mUdpBitDht->ConnectionRequest(&laddr, &(action.mDestId.id), action.mMode, start))
|
||||
{
|
||||
connectionRequested = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionReqFailed = true;
|
||||
}
|
||||
}
|
||||
else if (action.mMode == BITDHT_CONNECT_MODE_PROXY)
|
||||
{
|
||||
@ -1076,8 +1087,14 @@ int p3BitDht::doActions()
|
||||
std::cerr << std::endl;
|
||||
|
||||
int start = 1;
|
||||
mUdpBitDht->ConnectionRequest(&extaddr, &(action.mDestId.id), action.mMode, start);
|
||||
connectionRequested = true;
|
||||
if (mUdpBitDht->ConnectionRequest(&extaddr, &(action.mDestId.id), action.mMode, start))
|
||||
{
|
||||
connectionRequested = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionReqFailed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1086,12 +1103,7 @@ int p3BitDht::doActions()
|
||||
std::cerr << " is Discarded, as Own External Proxy Address is Not Stable!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_FRIEND);
|
||||
if (dpd)
|
||||
{
|
||||
dpd->mConnectLogic.updateCb(CSB_UPDATE_MODE_UNAVAILABLE);
|
||||
}
|
||||
connectionReqFailed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1115,6 +1127,12 @@ int p3BitDht::doActions()
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
|
||||
std::cerr << "PeerAction: Connection Attempt to: ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " has gone ahead";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_FRIEND);
|
||||
if (dpd)
|
||||
{
|
||||
@ -1130,6 +1148,26 @@ int p3BitDht::doActions()
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionReqFailed)
|
||||
{
|
||||
std::cerr << "PeerAction: Connection Attempt to: ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " is Discarded, as Mode is Unavailable";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_FRIEND);
|
||||
if (dpd)
|
||||
{
|
||||
dpd->mConnectLogic.updateCb(CSB_UPDATE_MODE_UNAVAILABLE);
|
||||
|
||||
dpd->mPeerReqStatusMsg = "Req Mode Unavailable";
|
||||
dpd->mPeerReqState = RSDHT_PEERREQ_STOPPED;
|
||||
dpd->mPeerReqMode = action.mMode;
|
||||
dpd->mPeerReqTS = now;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
class UdpStack
|
||||
{
|
||||
public:
|
||||
rsUdpStack(int testmode, struct sockaddr_in &local) { return; }
|
||||
UdpStack(struct sockaddr_in &local) { return; }
|
||||
|
||||
/* from pqiNetListener */
|
||||
@ -57,6 +58,9 @@ class rsUdpStack: public UdpStack, public pqiNetListener
|
||||
rsUdpStack(struct sockaddr_in &local)
|
||||
:UdpStack(local) { return; }
|
||||
|
||||
rsUdpStack(int testmode, struct sockaddr_in &local)
|
||||
:UdpStack(testmode, local) { return; }
|
||||
|
||||
/* from pqiNetListener */
|
||||
virtual bool resetListener(struct sockaddr_in &local)
|
||||
{
|
||||
@ -75,6 +79,9 @@ class rsFixedUdpStack: public UdpStack, public pqiNetListener
|
||||
rsFixedUdpStack(struct sockaddr_in &local)
|
||||
:UdpStack(local) { return; }
|
||||
|
||||
rsFixedUdpStack(int testmode, struct sockaddr_in &local)
|
||||
:UdpStack(testmode, local) { return; }
|
||||
|
||||
/* from pqiNetListener */
|
||||
virtual bool resetListener(struct sockaddr_in &local)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ static const int STUN_TTL = 64;
|
||||
* #define DEBUG_UDP_STUNNER_FILTER 1
|
||||
*/
|
||||
|
||||
#define DEBUG_UDP_STUNNER 1
|
||||
//#define DEBUG_UDP_STUNNER 1
|
||||
|
||||
const int32_t TOU_STUN_MAX_FAIL_COUNT = 3; /* 3 tries (could be higher?) */
|
||||
const int32_t TOU_STUN_MAX_SEND_RATE = 5; /* every 5 seconds */
|
||||
|
Loading…
x
Reference in New Issue
Block a user