mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 13:30:36 -04:00
- added a generic RsItem to the turtle router and the methods to route it. This makes the code much more elegant.
- suppressed a cross mutex lock bug that happened rarely while digging tunnels - changed FileDetails in ftServer so that it's now possiblt to search for hashes of files being downloaded - improved the search code in ftdatamultiplex - added some comments to the turtle code git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1964 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
03cbedb224
commit
b83e894640
7 changed files with 388 additions and 292 deletions
|
@ -127,36 +127,44 @@ bool ftDataMultiplex::FileDetails(std::string hash, uint32_t hintsflag, FileI
|
|||
#endif
|
||||
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
std::map<std::string, ftFileProvider *>::iterator sit;
|
||||
sit = mServers.find(hash);
|
||||
if (sit != mServers.end())
|
||||
|
||||
if(hintsflag & RS_FILE_HINTS_DOWNLOAD)
|
||||
{
|
||||
std::map<std::string, ftClient>::iterator cit;
|
||||
if (mClients.end() != (cit = mClients.find(hash)))
|
||||
{
|
||||
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::FileDetails()";
|
||||
std::cerr << " Found ftFileProvider!";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ftDataMultiplex::FileDetails()";
|
||||
std::cerr << " Found ftFileCreator!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
(sit->second)->FileDetails(info);
|
||||
return true;
|
||||
//(cit->second).mModule->FileDetails(info);
|
||||
(cit->second).mCreator->FileDetails(info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, ftClient>::iterator cit;
|
||||
if (mClients.end() != (cit = mClients.find(hash)))
|
||||
if(hintsflag & RS_FILE_HINTS_UPLOAD)
|
||||
{
|
||||
std::map<std::string, ftFileProvider *>::iterator sit;
|
||||
sit = mServers.find(hash);
|
||||
if (sit != mServers.end())
|
||||
{
|
||||
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::FileDetails()";
|
||||
std::cerr << " Found ftFileCreator!";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "ftDataMultiplex::FileDetails()";
|
||||
std::cerr << " Found ftFileProvider!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
//(cit->second).mModule->FileDetails(info);
|
||||
(cit->second).mCreator->FileDetails(info);
|
||||
return true;
|
||||
(sit->second)->FileDetails(info);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::FileDetails()";
|
||||
std::cerr << " Found nothing";
|
||||
|
|
|
@ -34,15 +34,6 @@ ftFileCreator::ftFileCreator(std::string path, uint64_t size, std::string hash,
|
|||
#endif
|
||||
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
|
||||
/* initialise the Transfer Lists */
|
||||
// mStart = recvd;
|
||||
// mEnd = recvd;
|
||||
|
||||
#ifdef TO_DO
|
||||
// we should init the chunk map with some bit array saying what is received and what is not!!
|
||||
chunkMap.setTotalReceived(recvd) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ftFileCreator::getFileData(uint64_t offset, uint32_t &chunk_size, void *data)
|
||||
|
@ -423,6 +414,13 @@ void ftFileCreator::setSourceMap(const std::string& peer_id,uint32_t chunk_size,
|
|||
{
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// At this point, we should cancel all file chunks that are asked to the
|
||||
// peer and which this peer actually doesn't possesses. Otherwise, the transfer may get stuck.
|
||||
// This should be done by:
|
||||
// - first setting the peer availability map
|
||||
// - then asking the chunkmap which chunks are being downloaded, but actually shouldn't
|
||||
// - cancelling them in the ftFileCreator, so that they can be re-asked later to another peer.
|
||||
//
|
||||
chunkMap.setPeerAvailabilityMap(peer_id,chunk_size,nb_chunks,compressed_map) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -367,24 +367,19 @@ bool ftServer::FileUploads(std::list<std::string> &hashs)
|
|||
|
||||
bool ftServer::FileDetails(std::string hash, uint32_t hintflags, FileInfo &info)
|
||||
{
|
||||
bool found = false;
|
||||
if (hintflags & RS_FILE_HINTS_DOWNLOAD)
|
||||
{
|
||||
//found = mFtDataplex->FileDetails(hash, hintflags, info);
|
||||
//
|
||||
// Use Controller for download searches.
|
||||
found = mFtController->FileDetails(hash, info);
|
||||
}
|
||||
else if (hintflags & RS_FILE_HINTS_UPLOAD)
|
||||
{
|
||||
found = mFtDataplex->FileDetails(hash, hintflags, info);
|
||||
}
|
||||
if(mFtController->FileDetails(hash, info))
|
||||
return true ;
|
||||
|
||||
if (!found)
|
||||
{
|
||||
found = mFtSearch->search(hash, 0, hintflags, info);
|
||||
}
|
||||
return found;
|
||||
if(hintflags & RS_FILE_HINTS_UPLOAD)
|
||||
if(mFtDataplex->FileDetails(hash, hintflags, info))
|
||||
return true ;
|
||||
|
||||
if(hintflags & ~(RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_DOWNLOAD))
|
||||
if(mFtSearch->search(hash, 0, hintflags, info))
|
||||
return true ;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue