mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Bugfixes for connection logic:
* added bool return value to ConnectionRequest. only returns false if MODE not allowed. * added checks for an existingConnectionRequest - results in a NOOP. * made each ConnectionRequest result in only one UDP start. * a START message will not kill a local ConnectionRequest (even in remotely started). * increased CONNECTION_TIMEOUT as this should never happen at this level. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4449 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bffaf6e5ef
commit
6609cec94d
@ -265,6 +265,8 @@ int bdConnectManager::requestConnection_direct(struct sockaddr_in *laddr, bdNode
|
||||
|
||||
if (checkExistingConnectionAttempt(target))
|
||||
{
|
||||
std::cerr << "bdConnectManager::requestConnection_direct() Existing ConnectionRequest... NOOP";
|
||||
std::cerr << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -326,8 +328,15 @@ int bdConnectManager::requestConnection_proxy(struct sockaddr_in *laddr, bdNodeI
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* create a bdConnect, and put into the queue */
|
||||
|
||||
if (checkExistingConnectionAttempt(target))
|
||||
{
|
||||
std::cerr << "bdConnectManager::requestConnection_proxy() Existing ConnectionRequest... NOOP";
|
||||
std::cerr << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* create a bdConnect, and put into the queue */
|
||||
bdConnectionRequest connreq;
|
||||
connreq.setupProxyConnection(laddr, target, mode);
|
||||
|
||||
@ -676,7 +685,7 @@ void bdConnectManager::iterateConnectionRequests()
|
||||
/* connection completed, doing UDP connection */
|
||||
if (now - it->second.mStateTS > BITDHT_CONNREQUEST_TIMEOUT_CONNECT)
|
||||
{
|
||||
std::cerr << "bdConnectManager::iterateConnectionAttempt() EXTCONNECT has reached timout ->????";
|
||||
std::cerr << "bdConnectManager::iterateConnectionAttempt() ERROR EXTCONNECT has reached timout -> SHOULD NEVER HAPPEN... restart this query:";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << it->second;
|
||||
std::cerr << std::endl;
|
||||
@ -854,9 +863,29 @@ void bdConnectManager::callbackConnectRequest(bdId *srcId, bdId *proxyId, bdId *
|
||||
{
|
||||
if (it->second.mState == BITDHT_CONNREQUEST_INPROGRESS)
|
||||
{
|
||||
std::cerr << "bdConnectManager::callbackConnectRequest() ERROR alt CR also in progress!";
|
||||
/* AT THIS POINT - WE SHOULD SWITCH IT INTO EXTCONNECT MODE????,
|
||||
* which will timeout - if it fails...
|
||||
* THIS is effectively the end of the connection attempt anyway.
|
||||
* if UDP succeeds or fails, will Kill either way.
|
||||
*/
|
||||
std::cerr << "bdConnectManager::callbackConnectRequest() ERROR ALT CR also in progress!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::cerr << "bdConnectManager::callbackConnectRequest() WARNING Switching ALT CR to EXTCONNECT Mode";
|
||||
std::cerr << std::endl;
|
||||
|
||||
time_t now = time(NULL);
|
||||
it->second.mState = BITDHT_CONNREQUEST_EXTCONNECT;
|
||||
it->second.mStateTS = now;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "bdConnectManager::callbackConnectRequest() No ALT CR - Good";
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
callbackConnect(srcId, proxyId, destId, mode, point, cbtype, errcode);
|
||||
return;
|
||||
@ -2233,7 +2262,8 @@ int bdConnectManager::recvedConnectionAck(bdId *id, bdId *srcConnAddr, bdId *des
|
||||
// Slightly different callback, use ConnAddr for start message!
|
||||
// Also callback to ConnectionRequest first.
|
||||
// ACTUALLY we are END, so shouldn't (AT This Point do this).
|
||||
callbackConnect(&(conn->mSrcConnAddr),&(conn->mProxyId),&(conn->mDestId),
|
||||
// MUST callback via ConnectRequest - to prevent duplicate REQUESTS.
|
||||
callbackConnectRequest(&(conn->mSrcConnAddr),&(conn->mProxyId),&(conn->mDestId),
|
||||
conn->mMode, conn->mPoint, BITDHT_CONNECT_CB_START,
|
||||
BITDHT_CONNECT_ERROR_NONE);
|
||||
|
||||
|
@ -42,7 +42,7 @@ class bdNodePublisher;
|
||||
#define BITDHT_CONNREQUEST_EXTCONNECT 4
|
||||
#define BITDHT_CONNREQUEST_DONE 5
|
||||
|
||||
#define BITDHT_CONNREQUEST_TIMEOUT_CONNECT 30
|
||||
#define BITDHT_CONNREQUEST_TIMEOUT_CONNECT 120 // MAKE THIS LARGE - SHOULD NEVER HAPPEN.
|
||||
#define BITDHT_CONNREQUEST_TIMEOUT_INPROGRESS 30
|
||||
#define BITDHT_CONNREQUEST_MAX_AGE 60
|
||||
|
||||
|
@ -317,7 +317,7 @@ virtual void removeFindNode(bdNodeId *id) = 0;
|
||||
virtual void findDhtValue(bdNodeId *id, std::string key, uint32_t mode) = 0;
|
||||
|
||||
/***** Connections Requests *****/
|
||||
virtual void ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start) = 0;
|
||||
virtual bool ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start) = 0;
|
||||
virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId, uint32_t mode, uint32_t loc, uint32_t answer) = 0;
|
||||
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags) = 0;
|
||||
|
||||
|
@ -1255,12 +1255,12 @@ int bdDebugCallback::dhtValueCallback(const bdNodeId *id, std::string key, uint3
|
||||
|
||||
|
||||
|
||||
void bdNodeManager::ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start)
|
||||
bool bdNodeManager::ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start)
|
||||
{
|
||||
std::cerr << "bdNodeManager::ConnectionRequest()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mConnMgr->requestConnection(laddr, target, mode, start);
|
||||
return mConnMgr->requestConnection(laddr, target, mode, start);
|
||||
}
|
||||
|
||||
void bdNodeManager::ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId, uint32_t mode, uint32_t loc, uint32_t answer)
|
||||
|
@ -121,7 +121,7 @@ virtual int getDhtQueries(std::map<bdNodeId, bdQueryStatus> &queries);
|
||||
virtual int getDhtQueryStatus(const bdNodeId *id, bdQuerySummary &query);
|
||||
|
||||
/***** Connection Interface ****/
|
||||
virtual void ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start);
|
||||
virtual bool ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start);
|
||||
virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId,
|
||||
uint32_t mode, uint32_t loc, uint32_t answer);
|
||||
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags);
|
||||
|
@ -125,11 +125,11 @@ void UdpBitDht::removeCallback(BitDhtCallback *cb)
|
||||
mBitDhtManager->removeCallback(cb);
|
||||
}
|
||||
|
||||
void UdpBitDht::ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start)
|
||||
bool UdpBitDht::ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start)
|
||||
{
|
||||
bdStackMutex stack(dhtMtx); /********** MUTEX LOCKED *************/
|
||||
|
||||
mBitDhtManager->ConnectionRequest(laddr, target, mode, start);
|
||||
return mBitDhtManager->ConnectionRequest(laddr, target, mode, start);
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ virtual void addCallback(BitDhtCallback *cb);
|
||||
virtual void removeCallback(BitDhtCallback *cb);
|
||||
|
||||
/***** Connections Requests *****/
|
||||
virtual void ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start);
|
||||
virtual bool ConnectionRequest(struct sockaddr_in *laddr, bdNodeId *target, uint32_t mode, uint32_t start);
|
||||
virtual void ConnectionAuth(bdId *srcId, bdId *proxyId, bdId *destId, uint32_t mode, uint32_t loc, uint32_t answer);
|
||||
virtual void ConnectionOptions(uint32_t allowedModes, uint32_t flags);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user