fixed a bug in download queue when ticking inactive files. Added a checkbox for showing cache transfers. Cleaned the dialog cleaning method.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2583 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-21 15:35:20 +00:00
parent 20fd24d7b8
commit 3b1006bfa4
5 changed files with 51 additions and 72 deletions

View file

@ -57,6 +57,7 @@
* #define CONTROL_DEBUG 1
* #define DEBUG_DWLQUEUE 1
*****/
#define DEBUG_DWLQUEUE 1
static const uint32_t SAVE_TRANSFERS_DELAY = 61 ; // save transfer progress every 61 seconds.
static const uint32_t INACTIVE_CHUNKS_CHECK_DELAY = 60 ; // time after which an inactive chunk is released
@ -410,16 +411,23 @@ void ftController::checkDownloadQueue()
// Check for inactive transfers.
//
time_t now = time(NULL) ;
uint32_t nb_moved = 0 ; // don't move more files than the size of the queue.
for(std::map<std::string,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end();++it)
for(std::map<std::string,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end() && nb_moved <= _max_active_downloads;++it)
if( it->second->mState != ftFileControl::QUEUED
&& it->second->mState != ftFileControl::PAUSED
&& now - it->second->mCreator->lastRecvTimeStamp() > (time_t)MAX_TIME_INACTIVE_REQUEUED)
&& now > it->second->mCreator->lastRecvTimeStamp() + (time_t)MAX_TIME_INACTIVE_REQUEUED)
{
#ifdef DEBUG_DWLQUEUE
std::cerr << " - Inactive file " << it->second->mName << " at position " << it->second->mQueuePosition << " moved to end of the queue. mState=" << it->second->mState << ", time lapse=" << now - it->second->mCreator->lastRecvTimeStamp() << std::endl ;
#endif
locked_bottomQueue(it->second->mQueuePosition) ;
#ifdef DEBUG_DWLQUEUE
std::cerr << " - Inactive file " << it->second->mName << " moved to end of the queue" << std::endl ;
std::cerr << " new position: " << it->second->mQueuePosition << std::endl ;
std::cerr << " new state: " << it->second->mState << std::endl ;
#endif
it->second->mCreator->resetRecvTimeStamp() ; // very important!
++nb_moved ;
}
}
@ -541,11 +549,6 @@ void ftController::locked_swapQueue(uint32_t pos1,uint32_t pos2)
locked_checkQueueElement(pos2) ;
}
//void ftController::checkQueueElements()
//{
// for(uint32_t pos=0;pos<_queue.size();++pos)
// checkQueueElement(pos) ;
//}
void ftController::locked_checkQueueElement(uint32_t pos)
{
_queue[pos]->mQueuePosition = pos ;

View file

@ -58,6 +58,11 @@ time_t ftFileCreator::lastRecvTimeStamp()
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
return _last_recv_time_t ;
}
void ftFileCreator::resetRecvTimeStamp()
{
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
_last_recv_time_t = time(NULL) ;
}
void ftFileCreator::closeFile()
{

View file

@ -76,8 +76,9 @@ class ftFileCreator: public ftFileProvider
// removes the designated file source from the chunkmap.
void removeFileSource(const std::string& peer_id) ;
// Returns the time stamp of the last data receive.
// Returns resets the time stamp of the last data receive.
time_t lastRecvTimeStamp() ;
void resetRecvTimeStamp() ;
// actually store data in the file, and update chunks info
//