mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixes for failed Proxy Connection Attempts:
- create Timeout Fn so it can be called by classes derived from pqissl. - set HIDDEN timeout to 30 seconds. - add reset_locked() calls on errors in pqisslproxy. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7039 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
45bd72203e
commit
06a582564d
@ -51,7 +51,9 @@ const uint32_t RS_NET_CONN_TCP_HIDDEN = 0x0008;
|
||||
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0010;
|
||||
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0020; /* coming soon */
|
||||
|
||||
// These are set in pqipersongroup.
|
||||
const uint32_t RS_TCP_STD_TIMEOUT_PERIOD = 5; /* 5 seconds! */
|
||||
const uint32_t RS_TCP_HIDDEN_TIMEOUT_PERIOD = 30; /* 30 seconds! */
|
||||
const uint32_t RS_UDP_STD_TIMEOUT_PERIOD = 80; /* 80 secs, allows UDP TTL to get to 40! - Plenty of time (30+80) = 110 secs */
|
||||
|
||||
class peerAddrInfo
|
||||
|
@ -620,12 +620,13 @@ int pqipersongrp::connectPeer(std::string id
|
||||
if (type == RS_NET_CONN_TCP_HIDDEN)
|
||||
{
|
||||
ptype = PQI_CONNECT_HIDDEN_TCP;
|
||||
timeout = RS_TCP_HIDDEN_TIMEOUT_PERIOD;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptype = PQI_CONNECT_TCP;
|
||||
}
|
||||
timeout = RS_TCP_STD_TIMEOUT_PERIOD;
|
||||
}
|
||||
#ifdef PGRP_DEBUG
|
||||
std::cerr << " pqipersongrp::connectPeer() connecting with TCP: Timeout :" << timeout;
|
||||
std::cerr << std::endl;
|
||||
|
@ -823,13 +823,8 @@ int pqissl::Initiate_Connection()
|
||||
*
|
||||
*/
|
||||
|
||||
int pqissl::Basic_Connection_Complete()
|
||||
bool pqissl::CheckConnectionTimeout()
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
||||
"pqissl::Basic_Connection_Complete()...");
|
||||
#endif
|
||||
|
||||
/* new TimeOut code. */
|
||||
if (time(NULL) > mTimeoutTS)
|
||||
{
|
||||
@ -841,10 +836,26 @@ int pqissl::Basic_Connection_Complete()
|
||||
|
||||
rslog(RSL_ALERT, pqisslzone, "pqissl::Basic_Connection_Complete() -> calling reset()");
|
||||
reset_locked();
|
||||
return -1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int pqissl::Basic_Connection_Complete()
|
||||
{
|
||||
#ifdef PQISSL_LOG_DEBUG
|
||||
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
||||
"pqissl::Basic_Connection_Complete()...");
|
||||
#endif
|
||||
|
||||
if (CheckConnectionTimeout())
|
||||
{
|
||||
// calls reset.
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (waiting != WAITING_SOCK_CONNECT)
|
||||
{
|
||||
rslog(RSL_ALERT, pqisslzone,
|
||||
|
@ -165,6 +165,9 @@ int Authorise_SSL_Connection();
|
||||
|
||||
int Extract_Failed_SSL_Certificate(); // try to get cert anyway.
|
||||
|
||||
// check connection timeout.
|
||||
bool CheckConnectionTimeout();
|
||||
|
||||
|
||||
//protected internal fns that are overloaded for udp case.
|
||||
virtual int net_internal_close(int fd);
|
||||
|
@ -96,6 +96,12 @@ int pqisslproxy::Basic_Connection_Complete()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (CheckConnectionTimeout())
|
||||
{
|
||||
// calls reset.
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
switch(mProxyState)
|
||||
{
|
||||
@ -127,6 +133,7 @@ int pqisslproxy::Basic_Connection_Complete()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
reset_locked();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -137,7 +144,7 @@ int pqisslproxy::Basic_Connection_Complete()
|
||||
std::cerr << "pqisslproxy::Basic_Connection_Complete() FAILED(2)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
reset_locked();
|
||||
return -1; // FAILURE.
|
||||
}
|
||||
|
||||
|
@ -351,21 +351,11 @@ int pqissludp::Basic_Connection_Complete()
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Basic_Connection_Complete()...");
|
||||
|
||||
|
||||
if (time(NULL) > mTimeoutTS)
|
||||
if (CheckConnectionTimeout())
|
||||
{
|
||||
std::string out = "pqissludp::Basic_Connection_Complete() Connection Timed Out. Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " Period: %lu", mConnectTimeout);
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
/* as sockfd is valid, this should close it all up */
|
||||
|
||||
reset_locked();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (waiting != WAITING_SOCK_CONNECT)
|
||||
{
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
|
Loading…
Reference in New Issue
Block a user