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
This commit is contained in:
csoler 2009-01-24 15:22:08 +00:00
parent 4b8420a17f
commit ed0fbb1fd7
2 changed files with 10 additions and 47 deletions

View File

@ -119,28 +119,20 @@ void ftController::run()
/* tick the transferModules */ /* tick the transferModules */
std::list<std::string> done; std::list<std::string> done;
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
std::map<std::string,ftFileControl>::iterator mit;
if (mDownloadingQueue.size() > 0)
{ {
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
for(it = mDownloadingQueue.begin(); it != mDownloadingQueue.end(); it++) std::map<std::string, ftFileControl>::iterator it;
for(it = mDownloads.begin(); it != mDownloads.end(); it++)
{ {
#ifdef CONTROL_DEBUG #ifdef CONTROL_DEBUG
std::cerr << "\tTicking: " << *it; std::cerr << "\tTicking: " << it->first;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
mit = mDownloads.find(*it);
if (mit != mDownloads.end()) if (it->second.mTransfer)
{ (it->second.mTransfer)->tick();
if (mit->second.mTransfer)
(mit->second.mTransfer)->tick();
}
else
{
mDownloadingQueue.erase(it);
}
} }
} }
@ -151,8 +143,6 @@ void ftController::run()
} }
mDone.clear(); mDone.clear();
/* adjust the Downloading queue*/
checkDownloadQueue();
} }
} }
@ -162,26 +152,9 @@ void ftController::run()
/* Called every 10 seconds or so */ /* Called every 10 seconds or so */
void ftController::checkDownloadQueue() void ftController::checkDownloadQueue()
{ {
uint32_t cnt = MAX_NUMBER_OF_DOWNLOADING_FILE - mDownloadingQueue.size(); /* */
if (cnt <= 0) return;
RsStackMutex stack(ctrlMutex);
std::map<std::string,ftFileControl>::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) bool ftController::FlagFileComplete(std::string hash)
@ -302,7 +275,6 @@ bool ftController::completeFile(std::string hash)
callbackCode = fc->mCallbackCode; callbackCode = fc->mCallbackCode;
mDownloads.erase(it); mDownloads.erase(it);
mDownloadingQueue.remove(it->first);
} /******* UNLOCKED ********/ } /******* UNLOCKED ********/
@ -642,10 +614,6 @@ bool ftController::FileRequest(std::string fname, std::string hash,
mDownloads[hash] = ftfc; mDownloads[hash] = ftfc;
mSlowQueue.push_back(hash); mSlowQueue.push_back(hash);
if (mDownloadingQueue.size() < MAX_NUMBER_OF_DOWNLOADING_FILE)
{
mDownloadingQueue.push_back(hash);
}
IndicateConfigChanged(); /* completed transfer -> save */ IndicateConfigChanged(); /* completed transfer -> save */
return true; return true;
@ -758,8 +726,6 @@ bool ftController::FileCancel(std::string hash)
//fc->mState = ftFileControl::ERROR_COMPLETION; //fc->mState = ftFileControl::ERROR_COMPLETION;
mDownloads.erase(mit); mDownloads.erase(mit);
mDownloadingQueue.remove(mit->first);
IndicateConfigChanged(); /* completed transfer -> save */ IndicateConfigChanged(); /* completed transfer -> save */
return true; return true;
} }

View File

@ -62,8 +62,6 @@ const uint32_t CB_CODE_MEDIA = 0x0004;
const uint32_t FC_TRANSFER_COMPLETE = 0x0001; const uint32_t FC_TRANSFER_COMPLETE = 0x0001;
const uint32_t MAX_NUMBER_OF_DOWNLOADING_FILE = 0x0002; //will be controller by user later
class ftFileControl class ftFileControl
{ {
public: public:
@ -192,8 +190,7 @@ bool setPeerState(ftTransferModule *tm, std::string id,
std::map<std::string, ftFileControl> mCompleted; std::map<std::string, ftFileControl> mCompleted;
std::map<std::string, ftFileControl> mDownloads; //include downloading and pending downloading std::map<std::string, ftFileControl> mDownloads;
std::list<std::string> mDownloadingQueue; //only include downloading file hashs
//std::map<std::string, ftTransferModule *> mTransfers; //std::map<std::string, ftTransferModule *> mTransfers;
//std::map<std::string, ftFileCreator *> mFileCreators; //std::map<std::string, ftFileCreator *> mFileCreators;