time out unused uploads

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@932 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
ewensun 2009-01-18 04:00:24 +00:00
parent 5480354492
commit 812cdd6bd6
5 changed files with 31 additions and 1 deletions

View File

@ -154,6 +154,8 @@ bool locked_handleServerRequest(ftFileProvider *provider,
ftDataSend *mDataSend;
ftSearch *mSearch;
std::string mOwnId;
friend class ftServer;
};
#endif

View File

@ -39,7 +39,7 @@ bool ftFileProvider::FileDetails(FileInfo &info)
info.size = mSize;
info.path = file_name;
info.fname = RsDirUtil::getTopDir(file_name);
info.lastTS = lastTS;
/* Use req_loc / req_size to estimate data rate */
return true;

View File

@ -183,6 +183,30 @@ void ftServer::run()
{
while(1)
{
//scan the uploads list in ftdatamultiplex and delete the items which time out
time_t now = time(NULL);
FileInfo info;
std::list<std::string> toDels;
std::map<std::string, ftFileProvider *>::iterator sit;
for(sit = mFtDataplex->mServers.begin(); sit != mFtDataplex->mServers.end(); sit++)
{
if (FileDetails(sit->first,RS_FILE_HINTS_UPLOAD,info))
{
if ((now - info.lastTS) > 5)
{
toDels.push_back(sit->first);
}
}
}
std::list<std::string>::iterator it;
for (it = toDels.begin();it != toDels.end(); it++)
{
sit = mFtDataplex->mServers.find(*it);
mFtDataplex->mServers.erase(sit);
delete sit->second;
}
#ifdef WIN32
Sleep(1000);
#else

View File

@ -96,6 +96,8 @@ static const int kRsFiStatusDone = 2;
double tfRate; /* in kbytes */
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
std::list<TransferInfo> peers;
time_t lastTS;
};
std::ostream &operator<<(std::ostream &out, const FileInfo &info);

View File

@ -96,6 +96,8 @@ static const int kRsFiStatusDone = 2;
double tfRate; /* in kbytes */
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
std::list<TransferInfo> peers;
time_t lastTS;
};
std::ostream &operator<<(std::ostream &out, const FileInfo &info);