From f110bad74caf5b5180bd1f0f69039a4ad4283b71 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 17 Apr 2011 16:22:03 +0000 Subject: [PATCH] changed policy for canceling cache files: only inactive transfers get canceled now. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4160 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 6 ++++-- libretroshare/src/ft/ftcontroller.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 129fab3f3..19ed08b91 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -346,18 +346,20 @@ void ftController::setPriority(const std::string& hash,DwlSpeed p) void ftController::cleanCacheDownloads() { std::vector toCancel ; + time_t now = time(NULL) ; { RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ for(std::map::iterator it(mDownloads.begin());it!=mDownloads.end();++it) - if ((it->second)->mFlags & RS_FILE_HINTS_CACHE) //check if a cache file is downloaded, if the case, timeout the transfer after TIMOUT_CACHE_FILE_TRANSFER + if ((it->second)->mFlags & RS_FILE_HINTS_CACHE) + // check if a cache file is downloaded, if the case, timeout the transfer after TIMOUT_CACHE_FILE_TRANSFER { #ifdef CONTROL_DEBUG std::cerr << "ftController::run() cache transfer found. age of this tranfer is :" << (int)(time(NULL) - (it->second)->mCreateTime); std::cerr << std::endl; #endif - if ((time(NULL) - (it->second)->mCreateTime) > TIMOUT_CACHE_FILE_TRANSFER) + if ((now - (it->second)->mCreator->lastRecvTimeStamp()) > TIMOUT_CACHE_FILE_TRANSFER) { #ifdef CONTROL_DEBUG std::cerr << "ftController::run() cache transfer to old. Cancelling transfer. Hash :" << (it->second)->mHash << ", time=" << (it->second)->mCreateTime << ", now = " << time(NULL) ; diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index 8892e1676..1df5e6554 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -60,7 +60,7 @@ class p3turtle ; const uint32_t FC_TRANSFER_COMPLETE = 0x0001; //timeouts in seconds -const int TIMOUT_CACHE_FILE_TRANSFER = 300; +const int TIMOUT_CACHE_FILE_TRANSFER = 800; class ftFileControl {