mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
* Increase UDP buffer size, as this might fix connection issue?
* Added peerId to udpstunner->exclusiveMode for debugging purposes. * added timeout for exclusive mode, this can happen if connection is lost at lower levels. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4489 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b3052e0208
commit
461378a3de
@ -63,7 +63,7 @@ int checkData(uint8 *data, int size, int idx);
|
|||||||
int setupBinaryCheck(std::string fname);
|
int setupBinaryCheck(std::string fname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const uint32 kMaxQueueSize = 100;
|
static const uint32 kMaxQueueSize = 300; // Was 100, which means max packet size of 100k (smaller than max packet size).
|
||||||
static const uint32 kMaxPktRetransmit = 20;
|
static const uint32 kMaxPktRetransmit = 20;
|
||||||
static const uint32 kMaxSynPktRetransmit = 100; // 100 => 200secs = over 3 minutes startup
|
static const uint32 kMaxSynPktRetransmit = 100; // 100 => 200secs = over 3 minutes startup
|
||||||
static const int TCP_STD_TTL = 64;
|
static const int TCP_STD_TTL = 64;
|
||||||
|
@ -49,6 +49,7 @@ const int32_t TOU_STUN_MAX_RECV_RATE = 25; /* every 25 seconds */
|
|||||||
const int32_t TOU_STUN_DEFAULT_TARGET_RATE = 15; /* 20 secs is minimum to keep a NAT UDP port open */
|
const int32_t TOU_STUN_DEFAULT_TARGET_RATE = 15; /* 20 secs is minimum to keep a NAT UDP port open */
|
||||||
const double TOU_SUCCESS_LPF_FACTOR = 0.90;
|
const double TOU_SUCCESS_LPF_FACTOR = 0.90;
|
||||||
|
|
||||||
|
#define EXCLUSIVE_MODE_TIMEOUT 300
|
||||||
|
|
||||||
UdpStunner::UdpStunner(UdpPublisher *pub)
|
UdpStunner::UdpStunner(UdpPublisher *pub)
|
||||||
:UdpSubReceiver(pub), stunMtx("UdpSubReceiver"), eaddrKnown(false), eaddrStable(false),
|
:UdpSubReceiver(pub), stunMtx("UdpSubReceiver"), eaddrKnown(false), eaddrStable(false),
|
||||||
@ -108,26 +109,48 @@ void UdpStunner::SimSymmetricNat()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int UdpStunner::grabExclusiveMode() /* returns seconds since last send/recv */
|
|
||||||
|
int UdpStunner::grabExclusiveMode(std::string holder) /* returns seconds since last send/recv */
|
||||||
{
|
{
|
||||||
RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/
|
RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/
|
||||||
|
time_t now = time(NULL);
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||||
std::cerr << "UdpStunner::setExclusiveMode();
|
std::cerr << "UdpStunner::grabExclusiveMode();"
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mExclusiveMode)
|
if (mExclusiveMode)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||||
std::cerr << "UdpStunner::setExclusiveMode() FAILED;
|
std::cerr << "UdpStunner::grabExclusiveMode() FAILED";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::cerr << "UdpStunner::grabExclusiveMode() FAILED, already held by: " << mExclusiveHolder;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "UdpStunner::grabExclusiveMode() Was Grabbed: " << now - mExclusiveModeTS;
|
||||||
|
std::cerr << " secs ago";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
/* This can happen if AUTH, but START never received! (occasionally).
|
||||||
|
*/
|
||||||
|
if (now - mExclusiveModeTS > EXCLUSIVE_MODE_TIMEOUT)
|
||||||
|
{
|
||||||
|
mExclusiveMode = false;
|
||||||
|
mForceRestun = true;
|
||||||
|
|
||||||
|
std::cerr << "UdpStunner::grabExclusiveMode() Held for too Long... TIMEOUT & Stun Forced";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t now = time(NULL);
|
|
||||||
mExclusiveMode = true;
|
mExclusiveMode = true;
|
||||||
mExclusiveModeTS = now;
|
mExclusiveModeTS = now;
|
||||||
|
mExclusiveHolder = holder;
|
||||||
|
|
||||||
int lastcomms = mStunLastRecvAny;
|
int lastcomms = mStunLastRecvAny;
|
||||||
if (mStunLastSendAny > lastcomms)
|
if (mStunLastSendAny > lastcomms)
|
||||||
@ -143,24 +166,26 @@ int UdpStunner::grabExclusiveMode() /* returns seconds since last send/recv */
|
|||||||
commsage = 1;
|
commsage = 1;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||||
std::cerr << "UdpStunner::setExclusiveMode() SUCCESS. last comms: " << commsage;
|
#endif
|
||||||
|
std::cerr << "UdpStunner::grabExclusiveMode() SUCCESS. last comms: " << commsage;
|
||||||
std::cerr << " ago";
|
std::cerr << " ago";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
std::cerr << "UdpStunner::grabExclusiveMode() Exclusive held by: " << mExclusiveHolder;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
return commsage;
|
return commsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UdpStunner::releaseExclusiveMode(bool forceStun)
|
int UdpStunner::releaseExclusiveMode(std::string holder, bool forceStun)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/
|
RsStackMutex stack(stunMtx); /********** LOCK MUTEX *********/
|
||||||
|
|
||||||
if (!mExclusiveMode)
|
if (!mExclusiveMode)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||||
|
#endif
|
||||||
std::cerr << "UdpStunner::cancelExclusiveMode() ERROR, not in exclusive Mode";
|
std::cerr << "UdpStunner::cancelExclusiveMode() ERROR, not in exclusive Mode";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,12 +208,21 @@ int UdpStunner::releaseExclusiveMode(bool forceStun)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (mExclusiveHolder != holder)
|
||||||
|
{
|
||||||
|
std::cerr << "UdpStunner::cancelExclusiveMode() ERROR release MisMatch: ";
|
||||||
|
std::cerr << " Original Grabber: ";
|
||||||
|
std::cerr << mExclusiveHolder;
|
||||||
|
std::cerr << " Releaser: ";
|
||||||
|
std::cerr << holder;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_UDP_STUNNER_FILTER
|
#ifdef DEBUG_UDP_STUNNER_FILTER
|
||||||
|
#endif
|
||||||
std::cerr << "UdpStunner::cancelExclusiveMode() Canceled. Was in ExclusiveMode for: " << now - mExclusiveModeTS;
|
std::cerr << "UdpStunner::cancelExclusiveMode() Canceled. Was in ExclusiveMode for: " << now - mExclusiveModeTS;
|
||||||
std::cerr << " secs";
|
std::cerr << " secs";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ virtual ~UdpStunner() { return; }
|
|||||||
void SimSymmetricNat();
|
void SimSymmetricNat();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int grabExclusiveMode(); /* returns seconds since last send/recv */
|
int grabExclusiveMode(std::string holder); /* returns seconds since last send/recv */
|
||||||
int releaseExclusiveMode(bool forceStun);
|
int releaseExclusiveMode(std::string holder, bool forceStun);
|
||||||
|
|
||||||
|
|
||||||
void setTargetStunPeriod(int32_t sec_per_stun);
|
void setTargetStunPeriod(int32_t sec_per_stun);
|
||||||
@ -156,6 +156,7 @@ bool locked_checkExternalAddress();
|
|||||||
|
|
||||||
bool mExclusiveMode; /* when this is switched on, the stunner stays silent (and extAddr is maintained) */
|
bool mExclusiveMode; /* when this is switched on, the stunner stays silent (and extAddr is maintained) */
|
||||||
time_t mExclusiveModeTS;
|
time_t mExclusiveModeTS;
|
||||||
|
std::string mExclusiveHolder;
|
||||||
bool mForceRestun;
|
bool mForceRestun;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user