mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added dynamic addign of direct sources from file lists. Useful for channels. Is called once every 61 seconds.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5850 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
93501bdc12
commit
b2e97407b5
@ -74,6 +74,9 @@ static const int32_t TIMOUT_CACHE_FILE_TRANSFER = 800 ; // time after which cac
|
|||||||
static const int32_t FT_FILECONTROL_QUEUE_ADD_END = 0 ;
|
static const int32_t FT_FILECONTROL_QUEUE_ADD_END = 0 ;
|
||||||
static const int32_t FT_FILECONTROL_QUEUE_ADD_AFTER_CACHE = 1 ;
|
static const int32_t FT_FILECONTROL_QUEUE_ADD_AFTER_CACHE = 1 ;
|
||||||
|
|
||||||
|
const uint32_t FT_CNTRL_STANDARD_RATE = 1024 * 1024;
|
||||||
|
const uint32_t FT_CNTRL_SLOW_RATE = 10 * 1024;
|
||||||
|
|
||||||
ftFileControl::ftFileControl()
|
ftFileControl::ftFileControl()
|
||||||
:mTransfer(NULL), mCreator(NULL),
|
:mTransfer(NULL), mCreator(NULL),
|
||||||
mState(DOWNLOADING), mSize(0), mFlags(0)
|
mState(DOWNLOADING), mSize(0), mFlags(0)
|
||||||
@ -232,6 +235,7 @@ void ftController::run()
|
|||||||
if(now > last_save_time + SAVE_TRANSFERS_DELAY)
|
if(now > last_save_time + SAVE_TRANSFERS_DELAY)
|
||||||
{
|
{
|
||||||
cleanCacheDownloads() ;
|
cleanCacheDownloads() ;
|
||||||
|
searchForDirectSources() ;
|
||||||
|
|
||||||
IndicateConfigChanged() ;
|
IndicateConfigChanged() ;
|
||||||
last_save_time = now ;
|
last_save_time = now ;
|
||||||
@ -277,6 +281,23 @@ void ftController::run()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ftController::searchForDirectSources()
|
||||||
|
{
|
||||||
|
std::cerr << "Searching for potential new direct sources" << std::endl;
|
||||||
|
|
||||||
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
|
FileInfo info ;
|
||||||
|
|
||||||
|
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++)
|
||||||
|
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED)
|
||||||
|
if(! (it->second->mFlags & RS_FILE_REQ_CACHE))
|
||||||
|
if(mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
|
||||||
|
for(std::list<TransferInfo>::const_iterator pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
||||||
|
if(it->second->mTransfer->addFileSource(pit->peerId)) /* if the sources don't exist already - add in */
|
||||||
|
setPeerState(it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mLinkMgr->isOnline( pit->peerId ));
|
||||||
|
}
|
||||||
|
|
||||||
void ftController::tickTransfers()
|
void ftController::tickTransfers()
|
||||||
{
|
{
|
||||||
// 1 - sort modules into arrays according to priority
|
// 1 - sort modules into arrays according to priority
|
||||||
@ -960,9 +981,6 @@ bool ftController::completeFile(std::string hash)
|
|||||||
/********************** Controller Access **********************/
|
/********************** Controller Access **********************/
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|
||||||
const uint32_t FT_CNTRL_STANDARD_RATE = 1024 * 1024;
|
|
||||||
const uint32_t FT_CNTRL_SLOW_RATE = 10 * 1024;
|
|
||||||
|
|
||||||
bool ftController::activate()
|
bool ftController::activate()
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
@ -192,6 +192,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||||||
virtual bool CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
virtual bool CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||||
|
|
||||||
void cleanCacheDownloads() ;
|
void cleanCacheDownloads() ;
|
||||||
|
void searchForDirectSources() ;
|
||||||
void tickTransfers() ;
|
void tickTransfers() ;
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
@ -166,6 +166,7 @@ bool ftTransferModule::addFileSource(const std::string& peerId)
|
|||||||
std::cerr << " adding peer: " << peerId << " to sourceList";
|
std::cerr << " adding peer: " << peerId << " to sourceList";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
return true ;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -175,8 +176,8 @@ bool ftTransferModule::addFileSource(const std::string& peerId)
|
|||||||
std::cerr << " peer: " << peerId << " already there";
|
std::cerr << " peer: " << peerId << " already there";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftTransferModule::removeFileSource(const std::string& peerId)
|
bool ftTransferModule::removeFileSource(const std::string& peerId)
|
||||||
|
Loading…
Reference in New Issue
Block a user