From ed0fbb1fd7aac64c5d41af0fe2a23fc9c742a3c2 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 24 Jan 2009 15:22:08 +0000 Subject: [PATCH] regression of ft/ftcontroler.{h,cc} to svn=932 because the 933 commit (download queue) causes a large scope bug. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@942 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 52 +++++----------------------- libretroshare/src/ft/ftcontroller.h | 5 +-- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 30d7f7ee8..2af200ebc 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -119,28 +119,20 @@ void ftController::run() /* tick the transferModules */ std::list done; std::list::iterator it; - std::map::iterator mit; - if (mDownloadingQueue.size() > 0) { RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ - for(it = mDownloadingQueue.begin(); it != mDownloadingQueue.end(); it++) + std::map::iterator it; + for(it = mDownloads.begin(); it != mDownloads.end(); it++) { #ifdef CONTROL_DEBUG - std::cerr << "\tTicking: " << *it; + std::cerr << "\tTicking: " << it->first; std::cerr << std::endl; #endif - mit = mDownloads.find(*it); - if (mit != mDownloads.end()) - { - if (mit->second.mTransfer) - (mit->second.mTransfer)->tick(); - } - else - { - mDownloadingQueue.erase(it); - } + + if (it->second.mTransfer) + (it->second.mTransfer)->tick(); } } @@ -150,9 +142,7 @@ void ftController::run() completeFile(*it); } mDone.clear(); - - /* adjust the Downloading queue*/ - checkDownloadQueue(); + } } @@ -162,26 +152,9 @@ void ftController::run() /* Called every 10 seconds or so */ void ftController::checkDownloadQueue() { - uint32_t cnt = MAX_NUMBER_OF_DOWNLOADING_FILE - mDownloadingQueue.size(); - if (cnt <= 0) return; - - RsStackMutex stack(ctrlMutex); - std::map::iterator mit; - mit = mDownloads.begin(); - while (cnt-- > 0) - { - while ((mit != mDownloads.end()) && (mit->second.mState != ftFileControl::DOWNLOADING)) - { mit++ ; } + /* */ + - if (mit != mDownloads.end()) - { - mDownloadingQueue.push_back(mit->first); - } - else - { - cnt = 0; - } - } } bool ftController::FlagFileComplete(std::string hash) @@ -302,7 +275,6 @@ bool ftController::completeFile(std::string hash) callbackCode = fc->mCallbackCode; mDownloads.erase(it); - mDownloadingQueue.remove(it->first); } /******* UNLOCKED ********/ @@ -642,10 +614,6 @@ bool ftController::FileRequest(std::string fname, std::string hash, mDownloads[hash] = ftfc; mSlowQueue.push_back(hash); - if (mDownloadingQueue.size() < MAX_NUMBER_OF_DOWNLOADING_FILE) - { - mDownloadingQueue.push_back(hash); - } IndicateConfigChanged(); /* completed transfer -> save */ return true; @@ -757,8 +725,6 @@ bool ftController::FileCancel(std::string hash) //fc->mState = ftFileControl::ERROR_COMPLETION; mDownloads.erase(mit); - - mDownloadingQueue.remove(mit->first); IndicateConfigChanged(); /* completed transfer -> save */ return true; diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index 24e92c9e2..9350805b5 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -62,8 +62,6 @@ const uint32_t CB_CODE_MEDIA = 0x0004; const uint32_t FC_TRANSFER_COMPLETE = 0x0001; -const uint32_t MAX_NUMBER_OF_DOWNLOADING_FILE = 0x0002; //will be controller by user later - class ftFileControl { public: @@ -192,8 +190,7 @@ bool setPeerState(ftTransferModule *tm, std::string id, std::map mCompleted; - std::map mDownloads; //include downloading and pending downloading - std::list mDownloadingQueue; //only include downloading file hashs + std::map mDownloads; //std::map mTransfers; //std::map mFileCreators;