mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
5480354492
commit
812cdd6bd6
@ -154,6 +154,8 @@ bool locked_handleServerRequest(ftFileProvider *provider,
|
||||
ftDataSend *mDataSend;
|
||||
ftSearch *mSearch;
|
||||
std::string mOwnId;
|
||||
|
||||
friend class ftServer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user