mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
connection bugfixes.
* Print DHT translations (for debugging) * enable all connection modes. * reduced timeout periods for testing. * kill connectionRequest after UDP Fail. (used to restart it). * fixed up UDP Fail / Connection Close code. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4450 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6609cec94d
commit
44b494e1fd
@ -29,12 +29,23 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#define FAILED_WAIT_TIME (300) //(1800) // 30 minutes.
|
#define TESTING_PERIODS 1
|
||||||
#define TCP_WAIT_TIME (60) // 1 minutes.
|
|
||||||
#define DIRECT_WAIT_TIME (60) // 1 minutes.
|
#ifdef TESTING_PERIODS
|
||||||
#define PROXY_WAIT_TIME (60) // 1 minutes.
|
#define FAILED_WAIT_TIME (1800) // 5 minutes.
|
||||||
#define RELAY_WAIT_TIME (60) // 1 minutes.
|
#define TCP_WAIT_TIME (10) // 1/6 minutes.
|
||||||
#define REVERSE_WAIT_TIME (300) // 5 minutes.
|
#define DIRECT_WAIT_TIME (10) // 1/6 minutes.
|
||||||
|
#define PROXY_WAIT_TIME (30) // 1/6 minutes.
|
||||||
|
#define RELAY_WAIT_TIME (30) // 1/6 minutes.
|
||||||
|
#define REVERSE_WAIT_TIME (30) // 1/2 minutes.
|
||||||
|
#else
|
||||||
|
#define FAILED_WAIT_TIME (1800) // 30 minutes.
|
||||||
|
#define TCP_WAIT_TIME (60) // 1 minutes.
|
||||||
|
#define DIRECT_WAIT_TIME (60) // 1 minutes.
|
||||||
|
#define PROXY_WAIT_TIME (60) // 1 minutes.
|
||||||
|
#define RELAY_WAIT_TIME (60) // 1 minutes.
|
||||||
|
#define REVERSE_WAIT_TIME (300) // 5 minutes.
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_DIRECT_ATTEMPTS (3)
|
#define MAX_DIRECT_ATTEMPTS (3)
|
||||||
#define MAX_PROXY_ATTEMPTS (3)
|
#define MAX_PROXY_ATTEMPTS (3)
|
||||||
|
@ -124,6 +124,11 @@ p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, p3NetMgr *nm,
|
|||||||
p3BdCallback *bdcb = new p3BdCallback(this);
|
p3BdCallback *bdcb = new p3BdCallback(this);
|
||||||
mUdpBitDht->addCallback(bdcb);
|
mUdpBitDht->addCallback(bdcb);
|
||||||
|
|
||||||
|
/* enable all modes */
|
||||||
|
mUdpBitDht->ConnectionOptions(
|
||||||
|
BITDHT_CONNECT_MODE_DIRECT | BITDHT_CONNECT_MODE_PROXY | BITDHT_CONNECT_MODE_RELAY,
|
||||||
|
BITDHT_CONNECT_OPTION_AUTOPROXY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p3BitDht::~p3BitDht()
|
p3BitDht::~p3BitDht()
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "pqi/p3netmgr.h"
|
#include "pqi/p3netmgr.h"
|
||||||
#include "pqi/pqimonitor.h"
|
#include "pqi/pqimonitor.h"
|
||||||
|
|
||||||
#define PEERNET_CONNECT_TIMEOUT 45
|
#define PEERNET_CONNECT_TIMEOUT 90 // Should be BIGGER than Higher level (but okay if not!)
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
@ -1884,49 +1884,12 @@ void p3BitDht::Feedback_ConnectionFailed(std::string pid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cerr << "p3BitDht::Feedback_ConnectionFailed() UDP Connection Failed: ";
|
||||||
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
return UdpConnectionFailed_locked(dpd);
|
return UdpConnectionFailed_locked(dpd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* shut id down */
|
|
||||||
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
|
||||||
dpd->mPeerConnectMsg = "UDP Failed";
|
|
||||||
|
|
||||||
if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)
|
|
||||||
{
|
|
||||||
std::cerr << "p3BitDht::monitorConnections() Request Active (Paused)... restarting";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
/* Push Back PeerAction */
|
|
||||||
PeerAction ca;
|
|
||||||
ca.mType = PEERNET_ACTION_TYPE_RESTARTREQ;
|
|
||||||
ca.mMode = dpd->mPeerConnectMode;
|
|
||||||
//ca.mProxyId = *proxyId;
|
|
||||||
//ca.mSrcId = *srcId;
|
|
||||||
ca.mDestId = dpd->mPeerConnectPeerId;
|
|
||||||
//ca.mPoint = point;
|
|
||||||
ca.mAnswer = BITDHT_CONNECT_ERROR_NONE;
|
|
||||||
|
|
||||||
mActions.push_back(ca);
|
|
||||||
|
|
||||||
// What the Action should do!
|
|
||||||
// tell it to keep going.
|
|
||||||
//struct sockaddr_in tmpaddr;
|
|
||||||
//bdsockaddr_clear(&tmpaddr);
|
|
||||||
//int start = 1;
|
|
||||||
//mUdpBitDht->ConnectionRequest(&tmpaddr, &(it->second.mPeerConnectPeerId.id), it->second.mPeerConnectMode, start);
|
|
||||||
}
|
|
||||||
// only an error if we initiated the connection.
|
|
||||||
else if (dpd->mPeerConnectPoint == BD_PROXY_CONNECTION_START_POINT)
|
|
||||||
{
|
|
||||||
std::cerr << "p3BitDht::monitorConnections() ERROR Request not active, can't stop";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void p3BitDht::Feedback_ConnectionClosed(std::string pid)
|
void p3BitDht::Feedback_ConnectionClosed(std::string pid)
|
||||||
{
|
{
|
||||||
@ -1942,18 +1905,69 @@ void p3BitDht::Feedback_ConnectionClosed(std::string pid)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "p3BitDht::monitorConnections() Active Connection Closed: ";
|
std::cerr << "p3BitDht::Feedback_ConnectionClosed() Active Connection Closed: ";
|
||||||
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
dpd->mConnectLogic.updateCb(CSB_UPDATE_DISCONNECTED);
|
return UdpConnectionFailed_locked(dpd);
|
||||||
|
}
|
||||||
|
|
||||||
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
|
||||||
dpd->mPeerConnectClosedTS = time(NULL);
|
void p3BitDht::UdpConnectionFailed_locked(DhtPeerDetails *dpd)
|
||||||
std::ostringstream msg;
|
{
|
||||||
msg << "Closed, Alive for: " << dpd->mPeerConnectClosedTS - dpd->mPeerConnectTS;
|
if (dpd->mPeerConnectState == RSDHT_PEERCONN_UDP_STARTED)
|
||||||
msg << " secs";
|
{
|
||||||
dpd->mPeerConnectMsg = msg.str();
|
std::cerr << "p3BitDht::UdpConnectionFailed_locked() UDP Connection Failed: ";
|
||||||
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
/* shut id down */
|
||||||
|
dpd->mConnectLogic.updateCb(CSB_UPDATE_FAILED_ATTEMPT);
|
||||||
|
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
||||||
|
dpd->mPeerConnectMsg = "UDP Failed";
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "p3BitDht::UdpConnectionFailed_locked() Active Connection Closed: ";
|
||||||
|
bdStdPrintNodeId(std::cerr, &(dpd->mDhtId.id));
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
dpd->mConnectLogic.updateCb(CSB_UPDATE_DISCONNECTED);
|
||||||
|
|
||||||
|
dpd->mPeerConnectState = RSDHT_PEERCONN_DISCONNECTED;
|
||||||
|
dpd->mPeerConnectClosedTS = time(NULL);
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << "Closed, Alive for: " << dpd->mPeerConnectClosedTS - dpd->mPeerConnectTS;
|
||||||
|
msg << " secs";
|
||||||
|
dpd->mPeerConnectMsg = msg.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dpd->mPeerReqState == RSDHT_PEERREQ_RUNNING)
|
||||||
|
{
|
||||||
|
std::cerr << "p3BitDht::monitorConnections() Request Active (Paused)... Killing for next Attempt";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
/* Push Back PeerAction */
|
||||||
|
PeerAction ca;
|
||||||
|
ca.mType = PEERNET_ACTION_TYPE_KILLREQ;
|
||||||
|
ca.mMode = dpd->mPeerConnectMode;
|
||||||
|
//ca.mProxyId = *proxyId;
|
||||||
|
//ca.mSrcId = *srcId;
|
||||||
|
ca.mDestId = dpd->mPeerConnectPeerId;
|
||||||
|
//ca.mPoint = point;
|
||||||
|
ca.mAnswer = BITDHT_CONNECT_ERROR_NONE;
|
||||||
|
|
||||||
|
mActions.push_back(ca);
|
||||||
|
}
|
||||||
|
// only an error if we initiated the connection.
|
||||||
|
else if (dpd->mPeerConnectPoint == BD_PROXY_CONNECTION_START_POINT)
|
||||||
|
{
|
||||||
|
std::cerr << "p3BitDht::monitorConnections() ERROR Request not active, can't stop";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -425,26 +425,26 @@ int p3BitDht::lookupRsId_locked(const bdNodeId *id, std::string &pid)
|
|||||||
|
|
||||||
int p3BitDht::storeTranslation_locked(const std::string pid)
|
int p3BitDht::storeTranslation_locked(const std::string pid)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
|
||||||
std::cerr << "p3BitDht::storeTranslation_locked(" << pid << ")";
|
std::cerr << "p3BitDht::storeTranslation_locked(" << pid << ")";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bdNodeId nid;
|
bdNodeId nid;
|
||||||
calculateNodeId(pid, &nid);
|
calculateNodeId(pid, &nid);
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
|
||||||
std::cerr << "p3BitDht::storeTranslation_locked() Converts to NodeId: ";
|
std::cerr << "p3BitDht::storeTranslation_locked() Converts to NodeId: ";
|
||||||
bdStdPrintNodeId(std::cerr, &(nid));
|
bdStdPrintNodeId(std::cerr, &(nid));
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mTransToNodeId[pid] = nid;
|
mTransToNodeId[pid] = nid;
|
||||||
mTransToRsId[nid] = pid;
|
mTransToRsId[nid] = pid;
|
||||||
|
|
||||||
#ifdef DEBUG_BITDHT_TRANSLATE
|
|
||||||
std::cerr << "p3BitDht::storeTranslation_locked() Success";
|
std::cerr << "p3BitDht::storeTranslation_locked() Success";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#ifdef DEBUG_BITDHT_TRANSLATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user