mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-30 09:56:14 -05:00
Cleaned up More debugging and started work on connections.
* switched off lots of debugging, and removed "common" messages, so we can focus on the actions. * Added extra debugging focused on the connections. * Removed "lastconnect" from p3LinkMgr. * added p3PeerMgr::updateLastConnect() fn, so this parameter will be stored. * added calls from p3LinkMgr at connect and disconnect. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4424 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f7ff55237e
commit
81dc1d77b7
@ -21,7 +21,11 @@
|
|||||||
|
|
||||||
#define PEERNET_CONNECT_TIMEOUT 45
|
#define PEERNET_CONNECT_TIMEOUT 45
|
||||||
|
|
||||||
#define DEBUG_BITDHT 1
|
/***
|
||||||
|
*
|
||||||
|
* #define DEBUG_BITDHT_COMMON 1 // These are the things that are called regularly (annoying for debugging specifics)
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int p3BitDht::add_peer(std::string id)
|
int p3BitDht::add_peer(std::string id)
|
||||||
@ -184,7 +188,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||||||
|
|
||||||
if ((mProxyStunner) && (mProxyStunner->needStunPeers()))
|
if ((mProxyStunner) && (mProxyStunner->needStunPeers()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT_COMMON
|
||||||
std::cerr << "p3BitDht::NodeCallback() Passing BitDHT Peer to DhtStunner: ";
|
std::cerr << "p3BitDht::NodeCallback() Passing BitDHT Peer to DhtStunner: ";
|
||||||
bdStdPrintId(std::cerr, id);
|
bdStdPrintId(std::cerr, id);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -195,7 +199,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||||||
|
|
||||||
if ((mDhtStunner) && (mDhtStunner->needStunPeers()))
|
if ((mDhtStunner) && (mDhtStunner->needStunPeers()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BITDHT
|
#ifdef DEBUG_BITDHT_COMMON
|
||||||
std::cerr << "p3BitDht::NodeCallback() Passing BitDHT Peer to DhtStunner: ";
|
std::cerr << "p3BitDht::NodeCallback() Passing BitDHT Peer to DhtStunner: ";
|
||||||
bdStdPrintId(std::cerr, id);
|
bdStdPrintId(std::cerr, id);
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -915,8 +919,10 @@ int p3BitDht::tick()
|
|||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
|
#ifdef PEERNET_DEBUG
|
||||||
std::cerr << "p3BitDht::tick() TIME: " << ctime(&now) << std::endl;
|
std::cerr << "p3BitDht::tick() TIME: " << ctime(&now) << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,6 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define DEBUG_BITDHT 1
|
|
||||||
|
|
||||||
/******************************************************************************************
|
/******************************************************************************************
|
||||||
********************************* Existing Interface *************************************
|
********************************* Existing Interface *************************************
|
||||||
******************************************************************************************/
|
******************************************************************************************/
|
||||||
|
@ -52,9 +52,10 @@ const int p3connectzone = 3431;
|
|||||||
|
|
||||||
/****
|
/****
|
||||||
* #define LINKMGR_DEBUG 1
|
* #define LINKMGR_DEBUG 1
|
||||||
|
* #define LINKMGR_DEBUG_CONNFAIL 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#define LINKMGR_DEBUG 1
|
#define LINKMGR_DEBUG_CONNFAIL 1
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define P3CONNMGR_NO_TCP_CONNECTIONS 1
|
* #define P3CONNMGR_NO_TCP_CONNECTIONS 1
|
||||||
@ -90,7 +91,6 @@ peerAddrInfo::peerAddrInfo()
|
|||||||
|
|
||||||
peerConnectState::peerConnectState()
|
peerConnectState::peerConnectState()
|
||||||
:id("unknown"),
|
:id("unknown"),
|
||||||
lastcontact(0),
|
|
||||||
connecttype(0),
|
connecttype(0),
|
||||||
lastavailable(0),
|
lastavailable(0),
|
||||||
lastattempt(0),
|
lastattempt(0),
|
||||||
@ -661,6 +661,8 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
{
|
{
|
||||||
bool doDhtAssist = false ;
|
bool doDhtAssist = false ;
|
||||||
bool updatePeerAddr = false;
|
bool updatePeerAddr = false;
|
||||||
|
bool updateLastContact = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
@ -694,6 +696,10 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
/* update address (should also come through from DISC) */
|
/* update address (should also come through from DISC) */
|
||||||
|
#ifdef LINKMGR_DEBUG_CONNFAIL
|
||||||
|
std::cerr << "p3LinkMgr::connectResult() Connect!: id: " << id << std::endl;
|
||||||
|
std::cerr << " Success: " << success << " flags: " << flags << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
std::cerr << "p3LinkMgr::connectResult() Connect!: id: " << id << std::endl;
|
std::cerr << "p3LinkMgr::connectResult() Connect!: id: " << id << std::endl;
|
||||||
@ -705,9 +711,9 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
/* change state */
|
/* change state */
|
||||||
it->second.state |= RS_PEER_S_CONNECTED;
|
it->second.state |= RS_PEER_S_CONNECTED;
|
||||||
it->second.actions |= RS_PEER_CONNECTED;
|
it->second.actions |= RS_PEER_CONNECTED;
|
||||||
it->second.lastcontact = time(NULL); /* time of connect */
|
|
||||||
it->second.connecttype = flags;
|
it->second.connecttype = flags;
|
||||||
|
|
||||||
|
updateLastContact = true; /* time of connect */
|
||||||
|
|
||||||
/* only update the peer's address if we were in a connect attempt.
|
/* only update the peer's address if we were in a connect attempt.
|
||||||
* Otherwise, they connected to us, and the address will be a
|
* Otherwise, they connected to us, and the address will be a
|
||||||
@ -741,6 +747,22 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef LINKMGR_DEBUG_CONNFAIL
|
||||||
|
std::cerr << "p3LinkMgr::connectResult() Disconnect/Fail: flags: " << flags << " id: " << id;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (it->second.inConnAttempt)
|
||||||
|
{
|
||||||
|
std::cerr << "p3LinkMgr::connectResult() Likely Connect Fail, as inConnAttempt Flag is set";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||||
|
{
|
||||||
|
std::cerr << "p3LinkMgr::connectResult() Likely DISCONNECT, as state set to Connected";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
it->second.inConnAttempt = false;
|
it->second.inConnAttempt = false;
|
||||||
|
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
@ -755,7 +777,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
it->second.actions |= RS_PEER_DISCONNECTED;
|
it->second.actions |= RS_PEER_DISCONNECTED;
|
||||||
mStatusChanged = true;
|
mStatusChanged = true;
|
||||||
|
|
||||||
it->second.lastcontact = time(NULL); /* time of disconnect */
|
updateLastContact = true; /* time of disconnect */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->second.connAddrs.size() >= 1)
|
if (it->second.connAddrs.size() >= 1)
|
||||||
@ -779,17 +801,22 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
raddr.mSrc = 0;
|
raddr.mSrc = 0;
|
||||||
|
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
std::cerr << "p3LinkMgr::connectResult() SUCCESS and we initiated connection... Updating Address";
|
std::cerr << "p3LinkMgr::connectResult() Success and we initiated connection... Updating Address";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mPeerMgr->updateCurrentAddress(id, raddr);
|
mPeerMgr->updateCurrentAddress(id, raddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateLastContact)
|
||||||
|
{
|
||||||
|
mPeerMgr->updateLastContact(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
std::cerr << "p3LinkMgr::connectResult() SUCCESS switching off DhtAssist for friend: " << id;
|
std::cerr << "p3LinkMgr::connectResult() Success switching off DhtAssist for friend: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
/* always switch it off now */
|
/* always switch it off now */
|
||||||
@ -800,7 +827,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
if (doDhtAssist)
|
if (doDhtAssist)
|
||||||
{
|
{
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
std::cerr << "p3LinkMgr::connectResult() FAIL, Enabling DhtAssist for: " << id;
|
std::cerr << "p3LinkMgr::connectResult() Fail, Enabling DhtAssist for: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mNetMgr->netAssistFriend(id,true) ;
|
mNetMgr->netAssistFriend(id,true) ;
|
||||||
@ -808,7 +835,7 @@ bool p3LinkMgr::connectResult(const std::string &id, bool success, uint32_t flag
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef LINKMGR_DEBUG
|
#ifdef LINKMGR_DEBUG
|
||||||
std::cerr << "p3LinkMgr::connectResult() FAIL, No DhtAssist, as No DHT visibility for: " << id;
|
std::cerr << "p3LinkMgr::connectResult() Fail, No DhtAssist, as No DHT visibility for: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class peerConnectState
|
|||||||
|
|
||||||
bool dhtVisible;
|
bool dhtVisible;
|
||||||
|
|
||||||
time_t lastcontact;
|
//time_t lastcontact;
|
||||||
|
|
||||||
uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL
|
uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL
|
||||||
time_t lastavailable;
|
time_t lastavailable;
|
||||||
|
@ -73,8 +73,6 @@ const uint32_t MIN_TIME_BETWEEN_NET_RESET = 5;
|
|||||||
* #define NETMGR_DEBUG_TICK 1
|
* #define NETMGR_DEBUG_TICK 1
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#define NETMGR_DEBUG 1
|
|
||||||
#define NETMGR_DEBUG_RESET 1
|
|
||||||
|
|
||||||
pqiNetStatus::pqiNetStatus()
|
pqiNetStatus::pqiNetStatus()
|
||||||
:mLocalAddrOk(false), mExtAddrOk(false), mExtAddrStableOk(false),
|
:mLocalAddrOk(false), mExtAddrOk(false), mExtAddrStableOk(false),
|
||||||
|
@ -790,7 +790,7 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
|||||||
it->second.ipAddrs.updateExtAddrs(addr);
|
it->second.ipAddrs.updateExtAddrs(addr);
|
||||||
it->second.serveraddr = addr.mAddr;
|
it->second.serveraddr = addr.mAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONN_DEBUG
|
#ifdef CONN_DEBUG
|
||||||
std::cerr << "p3PeerMgr::updatedCurrentAddress() Updated Address for: " << id;
|
std::cerr << "p3PeerMgr::updatedCurrentAddress() Updated Address for: " << id;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -801,7 +801,37 @@ bool p3PeerMgr::updateCurrentAddress(const std::string& id, const pqiIpAddres
|
|||||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool p3PeerMgr::updateLastContact(const std::string& id)
|
||||||
|
{
|
||||||
|
#ifdef CONN_DEBUG
|
||||||
|
std::cerr << "p3PeerMgr::updateLastContact() called for id : " << id << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
|
/* cannot be own id */
|
||||||
|
|
||||||
|
/* check if it is a friend */
|
||||||
|
std::map<std::string, peerState>::iterator it;
|
||||||
|
if (mFriendList.end() == (it = mFriendList.find(id)))
|
||||||
|
{
|
||||||
|
if (mOthersList.end() == (it = mOthersList.find(id)))
|
||||||
|
{
|
||||||
|
std::cerr << "p3PeerMgr::updateLastContact() ERROR peer id not found: " << id << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it->second.lastcontact = time(NULL);
|
||||||
|
|
||||||
|
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,8 +132,10 @@ void setOwnVisState(uint32_t visState);
|
|||||||
bool setLocalAddress(const std::string &id, struct sockaddr_in addr);
|
bool setLocalAddress(const std::string &id, struct sockaddr_in addr);
|
||||||
bool setExtAddress(const std::string &id, struct sockaddr_in addr);
|
bool setExtAddress(const std::string &id, struct sockaddr_in addr);
|
||||||
bool setDynDNS(const std::string &id, const std::string &dyndns);
|
bool setDynDNS(const std::string &id, const std::string &dyndns);
|
||||||
|
|
||||||
bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs);
|
bool updateAddressList(const std::string& id, const pqiIpAddrSet &addrs);
|
||||||
bool updateCurrentAddress(const std::string& id, const pqiIpAddress &addr);
|
bool updateCurrentAddress(const std::string& id, const pqiIpAddress &addr);
|
||||||
|
bool updateLastContact(const std::string& id);
|
||||||
|
|
||||||
bool setNetworkMode(const std::string &id, uint32_t netMode);
|
bool setNetworkMode(const std::string &id, uint32_t netMode);
|
||||||
bool setVisState(const std::string &id, uint32_t visState);
|
bool setVisState(const std::string &id, uint32_t visState);
|
||||||
|
Loading…
Reference in New Issue
Block a user