mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -05:00
Improved debugging by splitting the errors into multiple #defines.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5476 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5d482b9a6f
commit
42781f6a3e
@ -29,8 +29,10 @@
|
|||||||
/*
|
/*
|
||||||
* #define DEBUG_UDP_RELAY 1
|
* #define DEBUG_UDP_RELAY 1
|
||||||
* #define DEBUG_UDP_RELAY_PKTS 1
|
* #define DEBUG_UDP_RELAY_PKTS 1
|
||||||
|
* #define DEBUG_UDP_RELAY_ERRORS 1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define DEBUG_UDP_RELAY_ERRORS 1
|
||||||
|
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY
|
||||||
// DEBUG FUNCTION
|
// DEBUG FUNCTION
|
||||||
@ -93,7 +95,7 @@ int UdpRelayReceiver::addUdpPeer(UdpPeer *peer, UdpRelayAddrSet *endPoints,
|
|||||||
bool ok = (it == mStreams.end());
|
bool ok = (it == mStreams.end());
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
std::cerr << "UdpRelayReceiver::addUdpPeer() ERROR Peer already exists!" << std::endl;
|
std::cerr << "UdpRelayReceiver::addUdpPeer() ERROR Peer already exists!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -154,7 +156,7 @@ int UdpRelayReceiver::removeUdpPeer(UdpPeer *peer)
|
|||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
std::cerr << "UdpRelayReceiver::removeUdpPeer() Warning: Failed to find UdpPeer" << std::endl;
|
std::cerr << "UdpRelayReceiver::removeUdpPeer() Warning: Failed to find UdpPeer" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -173,7 +175,7 @@ int UdpRelayReceiver::removeUdpPeer(UdpPeer *peer)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
std::cerr << "UdpRelayReceiver::removeUdpPeer() ERROR failed to find Mapping" << std::endl;
|
std::cerr << "UdpRelayReceiver::removeUdpPeer() ERROR failed to find Mapping" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -270,7 +272,7 @@ int UdpRelayReceiver::checkRelays()
|
|||||||
|
|
||||||
if (rit->second.mBandwidth > rit->second.mBandwidthLimit)
|
if (rit->second.mBandwidth > rit->second.mBandwidthLimit)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
std::cerr << "UdpRelayReceiver::checkRelays() ";
|
std::cerr << "UdpRelayReceiver::checkRelays() ";
|
||||||
std::cerr << "Dropping Relay due to excessive Bandwidth: " << rit->second.mBandwidth;
|
std::cerr << "Dropping Relay due to excessive Bandwidth: " << rit->second.mBandwidth;
|
||||||
std::cerr << " Exceeding Limit: " << rit->second.mBandwidthLimit;
|
std::cerr << " Exceeding Limit: " << rit->second.mBandwidthLimit;
|
||||||
@ -283,7 +285,7 @@ int UdpRelayReceiver::checkRelays()
|
|||||||
}
|
}
|
||||||
else if (now - rit->second.mLastTS > RELAY_TIMEOUT)
|
else if (now - rit->second.mLastTS > RELAY_TIMEOUT)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
/* if haven't transmitted for ages -> drop */
|
/* if haven't transmitted for ages -> drop */
|
||||||
std::cerr << "UdpRelayReceiver::checkRelays() ";
|
std::cerr << "UdpRelayReceiver::checkRelays() ";
|
||||||
std::cerr << "Dropping Relay due to Timeout: " << rit->first;
|
std::cerr << "Dropping Relay due to Timeout: " << rit->first;
|
||||||
@ -354,7 +356,7 @@ int UdpRelayReceiver::addUdpRelay(UdpRelayAddrSet *addrSet, int &relayClass, uin
|
|||||||
int ok = (rit == mRelays.end());
|
int ok = (rit == mRelays.end());
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
std::cerr << "UdpRelayReceiver::addUdpRelay() ERROR Peer already exists!" << std::endl;
|
std::cerr << "UdpRelayReceiver::addUdpRelay() ERROR Peer already exists!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -381,7 +383,7 @@ int UdpRelayReceiver::addUdpRelay(UdpRelayAddrSet *addrSet, int &relayClass, uin
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_UDP_RELAY
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
std::cerr << "UdpRelayReceiver::addUdpRelay() WARNING Too many Relays!" << std::endl;
|
std::cerr << "UdpRelayReceiver::addUdpRelay() WARNING Too many Relays!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -731,8 +733,8 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
|||||||
|
|
||||||
if (!isUdpRelayPacket(data, size))
|
if (!isUdpRelayPacket(data, size))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_RELAY_PKTS
|
#ifdef DEBUG_UDP_RELAY
|
||||||
std::cerr << "UdpRelayReceiver::recvPkt() is Not RELAY Pkt";
|
std::cerr << "UdpRelayReceiver::recvPkt() ERROR: is Not RELAY Pkt";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
@ -742,6 +744,10 @@ int UdpRelayReceiver::recvPkt(void *data, int size, struct sockaddr_in &from)
|
|||||||
UdpRelayAddrSet addrSet;
|
UdpRelayAddrSet addrSet;
|
||||||
if (!extractUdpRelayAddrSet(data, size, addrSet))
|
if (!extractUdpRelayAddrSet(data, size, addrSet))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_UDP_RELAY_ERRORS
|
||||||
|
std::cerr << "UdpRelayReceiver::recvPkt() ERROR: cannot extract Addresses";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
/* fails most basic test, drop */
|
/* fails most basic test, drop */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user