mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 15:28:28 -05:00
added non aggressive mode option to turtle router to make distant chat happy
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7856 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d886c34233
commit
817aa793fc
@ -872,7 +872,7 @@ void DistantChatService::startClientDistantChatConnection(const RsGxsId& to_gxs_
|
||||
std::cerr << "Asking turtle router to monitor tunnels for hash " << hash << std::endl;
|
||||
#endif
|
||||
|
||||
mTurtle->monitorTunnels(hash,this) ;
|
||||
mTurtle->monitorTunnels(hash,this,false) ;
|
||||
|
||||
// spawn a status item so as to open the chat window.
|
||||
RsChatMsgItem *item = new RsChatMsgItem;
|
||||
|
@ -644,7 +644,7 @@ void ftController::locked_checkQueueElement(uint32_t pos)
|
||||
_queue[pos]->mState = ftFileControl::DOWNLOADING ;
|
||||
|
||||
if(_queue[pos]->mFlags & RS_FILE_REQ_ANONYMOUS_ROUTING)
|
||||
mTurtle->monitorTunnels(_queue[pos]->mHash,mFtServer) ;
|
||||
mTurtle->monitorTunnels(_queue[pos]->mHash,mFtServer,true) ;
|
||||
}
|
||||
|
||||
if(pos >= _max_active_downloads && _queue[pos]->mState != ftFileControl::QUEUED && _queue[pos]->mState != ftFileControl::PAUSED)
|
||||
@ -1276,7 +1276,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
||||
// We check that flags are consistent.
|
||||
|
||||
if(flags & RS_FILE_REQ_ANONYMOUS_ROUTING)
|
||||
mTurtle->monitorTunnels(hash,mFtServer) ;
|
||||
mTurtle->monitorTunnels(hash,mFtServer,true) ;
|
||||
|
||||
bool assume_availability = flags & RS_FILE_REQ_CACHE ; // assume availability for cache files
|
||||
|
||||
|
@ -110,7 +110,7 @@ class RsTurtle
|
||||
// tunnels for the given hash. The download should be driven by the file
|
||||
// transfer module by calling ftServer::FileRequest().
|
||||
//
|
||||
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service) = 0 ;
|
||||
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service,bool use_aggressive_mode) = 0 ;
|
||||
|
||||
// Tells the turtle router to stop handling tunnels for the given file hash. Traditionally this should
|
||||
// be called after calling ftServer::fileCancel().
|
||||
|
@ -374,7 +374,8 @@ void p3turtle::manageTunnels()
|
||||
std::cerr << "Total speed = " << total_speed << ", tunel factor = " << tunnel_keeping_factor << " new time = " << time_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor) << std::endl;
|
||||
#endif
|
||||
|
||||
if( (it->second.tunnels.empty() && now >= it->second.last_digg_time+EMPTY_TUNNELS_DIGGING_TIME) || now >= it->second.last_digg_time + time_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor))
|
||||
if( (it->second.tunnels.empty() && now >= it->second.last_digg_time+EMPTY_TUNNELS_DIGGING_TIME)
|
||||
|| (it->second.use_aggressive_mode && now >= it->second.last_digg_time + time_t(REGULAR_TUNNEL_DIGGING_TIME*tunnel_keeping_factor)))
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "pushed hash " << it->first << ", for digging. Old = " << now - it->second.last_digg_time << std::endl;
|
||||
@ -1818,7 +1819,7 @@ TurtleRequestId p3turtle::turtleSearch(const LinearizedExpression& expr)
|
||||
return id ;
|
||||
}
|
||||
|
||||
void p3turtle::monitorTunnels(const RsFileHash& hash,RsTurtleClientService *client_service)
|
||||
void p3turtle::monitorTunnels(const RsFileHash& hash,RsTurtleClientService *client_service,bool allow_multi_tunnels)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -197,9 +197,10 @@ class TurtleHashInfo
|
||||
{
|
||||
public:
|
||||
std::vector<TurtleTunnelId> tunnels ; // list of active tunnel ids for this file hash
|
||||
TurtleRequestId last_request ; // last request for the tunnels of this hash
|
||||
time_t last_digg_time ; // last time the tunnel digging happenned.
|
||||
RsTurtleClientService *service ; // client service to which items should be sent. Never NULL.
|
||||
TurtleRequestId last_request ; // last request for the tunnels of this hash
|
||||
time_t last_digg_time ; // last time the tunnel digging happenned.
|
||||
RsTurtleClientService *service ; // client service to which items should be sent. Never NULL.
|
||||
bool use_aggressive_mode ; // allow to re-digg tunnels even when some are already available
|
||||
};
|
||||
|
||||
// Subclassing:
|
||||
@ -251,7 +252,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||
// This function should be called in addition to ftServer::FileRequest() so that the turtle router
|
||||
// automatically provide tunnels for the file to download.
|
||||
//
|
||||
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service) ;
|
||||
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service, bool allow_multi_tunnels) ;
|
||||
|
||||
/// This should be called when canceling a file download, so that the turtle router stops
|
||||
/// handling tunnels for this file.
|
||||
|
Loading…
x
Reference in New Issue
Block a user