From 817aa793fc0a239c4101752c26cb7e6054299481 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 22 Jan 2015 20:25:39 +0000 Subject: [PATCH] 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 --- libretroshare/src/chat/distantchat.cc | 2 +- libretroshare/src/ft/ftcontroller.cc | 4 ++-- libretroshare/src/retroshare/rsturtle.h | 2 +- libretroshare/src/turtle/p3turtle.cc | 5 +++-- libretroshare/src/turtle/p3turtle.h | 9 +++++---- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/chat/distantchat.cc b/libretroshare/src/chat/distantchat.cc index 7782380f8..d2a882c68 100644 --- a/libretroshare/src/chat/distantchat.cc +++ b/libretroshare/src/chat/distantchat.cc @@ -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; diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index c50706d94..bef0970ef 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -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 diff --git a/libretroshare/src/retroshare/rsturtle.h b/libretroshare/src/retroshare/rsturtle.h index 275253467..11fb98df0 100644 --- a/libretroshare/src/retroshare/rsturtle.h +++ b/libretroshare/src/retroshare/rsturtle.h @@ -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(). diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index a195e30e1..24ddd877a 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -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 ******/ diff --git a/libretroshare/src/turtle/p3turtle.h b/libretroshare/src/turtle/p3turtle.h index ef6011a37..1594c8fd0 100644 --- a/libretroshare/src/turtle/p3turtle.h +++ b/libretroshare/src/turtle/p3turtle.h @@ -197,9 +197,10 @@ class TurtleHashInfo { public: std::vector 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.