From 6fee3eeeb78c26b93cc386a26fa5a574496d3b47 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 30 Apr 2010 21:07:21 +0000 Subject: [PATCH] corrected bug about persistence of default chunk strategy git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2817 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 20 +++++++++++++++++++- libretroshare/src/ft/ftserver.cc | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 2f9296019..165b48762 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -519,6 +519,7 @@ void ftController::locked_topQueue(uint32_t pos) locked_checkQueueElement(p) ; } _queue[0]=tmp ; + locked_checkQueueElement(0) ; } void ftController::locked_bottomQueue(uint32_t pos) @@ -552,8 +553,11 @@ void ftController::locked_checkQueueElement(uint32_t pos) { _queue[pos]->mQueuePosition = pos ; - if(pos < _max_active_downloads) + if(pos < _max_active_downloads && _queue[pos]->mState != ftFileControl::PAUSED) { + if(_queue[pos]->mState == ftFileControl::QUEUED) + _queue[pos]->mCreator->resetRecvTimeStamp() ; + _queue[pos]->mState = ftFileControl::DOWNLOADING ; if(_queue[pos]->mFlags & RS_FILE_HINTS_NETWORK_WIDE) @@ -1150,6 +1154,9 @@ bool ftController::FileRequest(std::string fname, std::string hash, ftFileCreator *fc = new ftFileCreator(savepath, size, hash); ftTransferModule *tm = new ftTransferModule(fc, mDataplex,this); +#ifdef CONTROL_DEBUG + std::cerr << "Note: setting chunk strategy to " << mDefaultChunkStrategy <setChunkStrategy(mDefaultChunkStrategy) ; /* add into maps */ @@ -1950,9 +1957,17 @@ bool ftController::loadConfigMap(std::map &configMap) if (configMap.end() != (mit = configMap.find(default_chunk_strategy_ss))) { if(mit->second == "STREAMING") + { setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_STREAMING) ; + std::cerr << "Note: loading default value for chunk strategy: streaming" << std::endl; + } else if(mit->second == "RANDOM") + { setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) ; + std::cerr << "Note: loading default value for chunk strategy: random" << std::endl; + } + else + std::cerr << "**** ERROR ***: Unknown value for default chunk strategy in keymap." << std::endl ; } return true; @@ -1966,6 +1981,9 @@ FileChunksInfo::ChunkStrategy ftController::defaultChunkStrategy() void ftController::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy S) { RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ +#ifdef CONTROL_DEBUG + std::cerr << "Note: in frController: setting chunk strategy to " << S << std::endl ; +#endif mDefaultChunkStrategy = S ; IndicateConfigChanged() ; } diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 7e63f126f..2e7627952 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -272,9 +272,9 @@ bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStr { return mFtController->setChunkStrategy(hash,s); } -void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) +void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s) { - mFtController->defaultChunkStrategy() ; + mFtController->setDefaultChunkStrategy(s) ; } FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy() {