timeout on fil index cache transfer \n Set fileIndex cache transfer timeout to 300sec \n Remove the downloads item for file index cache transfer

Merge branch 'fiIndexCacheTransfertImprove'


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1180 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-05-06 20:48:32 +00:00
parent 22dea2ceea
commit e34173759e
6 changed files with 48 additions and 13 deletions

View File

@ -67,7 +67,7 @@ ftFileControl::ftFileControl(std::string fname,
ftFileCreator *fc, ftTransferModule *tm, uint32_t cb)
:mName(fname), mCurrentPath(tmppath), mDestination(dest),
mTransfer(tm), mCreator(fc), mState(0), mHash(hash),
mSize(size), mFlags(0), mDoCallback(false), mCallbackCode(cb)
mSize(size), mFlags(flags), mDoCallback(false), mCallbackCode(cb)
{
if (cb)
mDoCallback = true;
@ -88,8 +88,8 @@ void ftController::setFtSearchNExtra(ftSearch *search, ftExtraList *list)
void ftController::run()
{
/* check the queues */
/* check the queues */
while(1)
{
#ifdef WIN32
@ -99,8 +99,8 @@ void ftController::run()
#endif
#ifdef CONTROL_DEBUG
//std::cerr << "ftController::run()";
//std::cerr << std::endl;
std::cerr << "ftController::run()";
std::cerr << std::endl;
#endif
bool doPending = false;
{
@ -124,7 +124,8 @@ void ftController::run()
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
std::map<std::string, ftFileControl>::iterator it;
for(it = mDownloads.begin(); it != mDownloads.end(); it++)
std::map<std::string, ftFileControl> currentDownloads = *(&mDownloads);
for(it = currentDownloads.begin(); it != currentDownloads.end(); it++)
{
#ifdef CONTROL_DEBUG
@ -132,8 +133,26 @@ void ftController::run()
std::cerr << std::endl;
#endif
if (it->second.mTransfer)
(it->second.mTransfer)->tick();
if (it->second.mTransfer) {
(it->second.mTransfer)->tick();
//check if a cache file is downloaded, if the case, timeout the transfer after TIMOUT_CACHE_FILE_TRANSFER
if ((it->second).mFlags & RS_FILE_HINTS_CACHE) {
#ifdef CONTROL_DEBUG
std::cerr << "ftController::run() cache transfer found. age of this tranfer is :" << (int)(time(NULL) - (it->second).mCreateTime);
std::cerr << std::endl;
#endif
if ((time(NULL) - (it->second).mCreateTime) > TIMOUT_CACHE_FILE_TRANSFER) {
#ifdef CONTROL_DEBUG
std::cerr << "ftController::run() cache transfer to old. Cancelling transfer. Hash :" << (it->second).mHash;
std::cerr << std::endl;
#endif
this->FileCancel((it->second).mHash);
}
}
}
}
}
@ -143,7 +162,6 @@ void ftController::run()
completeFile(*it);
}
mDone.clear();
}
}
@ -661,12 +679,15 @@ bool ftController::FileRequest(std::string fname, std::string hash,
/* add into maps */
ftFileControl ftfc(fname, savepath, destination,
size, hash, flags, fc, tm, callbackCode);
ftfc.mCreateTime = time(NULL);
#ifdef CONTROL_DEBUG
std::cerr << "ftController::FileRequest() Created ftFileCreator @: " << fc;
std::cerr << std::endl;
std::cerr << "ftController::FileRequest() Created ftTransModule @: " << tm;
std::cerr << std::endl;
std::cerr << "ftController::FileRequest() Created ftFileControl." ;
std::cerr << std::endl;
#endif
/* add to ClientModule */
@ -959,6 +980,7 @@ bool ftController::FileDetails(std::string hash, FileInfo &info)
/* extract details */
info.hash = hash;
info.fname = it->second.mName;
info.flags = it->second.mFlags;
info.path = RsDirUtil::removeTopDir(it->second.mDestination); /* remove fname */
/* get list of sources from transferModule */

View File

@ -56,12 +56,11 @@ class ftDataMultiplex;
#include <map>
const uint32_t CB_CODE_CACHE = 0x0001;
const uint32_t CB_CODE_EXTRA = 0x0002;
const uint32_t CB_CODE_MEDIA = 0x0004;
const uint32_t FC_TRANSFER_COMPLETE = 0x0001;
//timeouts in seconds
const int TIMOUT_CACHE_FILE_TRANSFER = 300;
class ftFileControl
{
public:
@ -84,6 +83,7 @@ class ftFileControl
uint32_t mFlags;
bool mDoCallback;
uint32_t mCallbackCode;
time_t mCreateTime;
};
class ftPendingRequest

View File

@ -356,7 +356,6 @@ int ftServer::RequestDirDetails(std::string uid, std::string path, DirDetails &d
std::cerr << "mFiStore not SET yet = FAIL";
std::cerr << std::endl;
}
#endif
return mFiStore->RequestDirDetails(uid, path, details);
}

View File

@ -81,6 +81,10 @@ const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
const uint32_t RS_FILE_EXTRA_DELETE = 0x0010;
const uint32_t CB_CODE_CACHE = 0x0001;
const uint32_t CB_CODE_EXTRA = 0x0002;
const uint32_t CB_CODE_MEDIA = 0x0004;
class RsFiles
{

View File

@ -383,6 +383,12 @@ void TransfersDialog::insertTransfers()
continue;
}
//if file transfer is a cache file index file, don't show it
if (info.flags & CB_CODE_CACHE)
{
continue;
}
std::list<TransferInfo>::iterator pit;
for(pit = info.peers.begin(); pit != info.peers.end(); pit++)
{

View File

@ -81,6 +81,10 @@ const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
const uint32_t RS_FILE_EXTRA_DELETE = 0x0010;
const uint32_t CB_CODE_CACHE = 0x0001;
const uint32_t CB_CODE_EXTRA = 0x0002;
const uint32_t CB_CODE_MEDIA = 0x0004;
class RsFiles
{