mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 14:42:51 -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
5 changed files with 31 additions and 1 deletions
|
@ -154,6 +154,8 @@ bool locked_handleServerRequest(ftFileProvider *provider,
|
||||||
ftDataSend *mDataSend;
|
ftDataSend *mDataSend;
|
||||||
ftSearch *mSearch;
|
ftSearch *mSearch;
|
||||||
std::string mOwnId;
|
std::string mOwnId;
|
||||||
|
|
||||||
|
friend class ftServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool ftFileProvider::FileDetails(FileInfo &info)
|
||||||
info.size = mSize;
|
info.size = mSize;
|
||||||
info.path = file_name;
|
info.path = file_name;
|
||||||
info.fname = RsDirUtil::getTopDir(file_name);
|
info.fname = RsDirUtil::getTopDir(file_name);
|
||||||
|
info.lastTS = lastTS;
|
||||||
/* Use req_loc / req_size to estimate data rate */
|
/* Use req_loc / req_size to estimate data rate */
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -183,6 +183,30 @@ void ftServer::run()
|
||||||
{
|
{
|
||||||
while(1)
|
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
|
#ifdef WIN32
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -96,6 +96,8 @@ static const int kRsFiStatusDone = 2;
|
||||||
double tfRate; /* in kbytes */
|
double tfRate; /* in kbytes */
|
||||||
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||||
std::list<TransferInfo> peers;
|
std::list<TransferInfo> peers;
|
||||||
|
|
||||||
|
time_t lastTS;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||||
|
|
|
@ -96,6 +96,8 @@ static const int kRsFiStatusDone = 2;
|
||||||
double tfRate; /* in kbytes */
|
double tfRate; /* in kbytes */
|
||||||
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||||
std::list<TransferInfo> peers;
|
std::list<TransferInfo> peers;
|
||||||
|
|
||||||
|
time_t lastTS;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue