mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 21:34:10 -05:00
commit
c6ffe07cd1
@ -923,7 +923,12 @@ bool RemoteDirectoryStorage::deserialiseUpdateDirEntry(const EntryIndex& indx,co
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RemoteDirectoryStorage::searchHash(const RsFileHash& hash, EntryIndex& result) const
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||||
|
|
||||||
|
return mFileHierarchy->searchHash(hash,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,6 +203,18 @@ public:
|
|||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
time_t& lastSweepTime() { return mLastSweepTime ; }
|
time_t& lastSweepTime() { return mLastSweepTime ; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief searchHash
|
||||||
|
* Looks into local database of shared files for the given hash.
|
||||||
|
* \param hash hash to look for
|
||||||
|
* \param results Entry index of the file that is found
|
||||||
|
* \return
|
||||||
|
* true is a file is found
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
virtual int searchHash(const RsFileHash& hash, EntryIndex& results) const ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
time_t mLastSweepTime ;
|
time_t mLastSweepTime ;
|
||||||
};
|
};
|
||||||
|
@ -1073,24 +1073,39 @@ bool p3FileDatabase::search(const RsFileHash &hash, FileSearchFlags hintflags, F
|
|||||||
RsFileHash real_hash ;
|
RsFileHash real_hash ;
|
||||||
EntryIndex indx;
|
EntryIndex indx;
|
||||||
|
|
||||||
if(!mLocalSharedDirs->searchHash(hash,real_hash,indx))
|
if(mLocalSharedDirs->searchHash(hash,real_hash,indx))
|
||||||
return false;
|
{
|
||||||
|
mLocalSharedDirs->getFileInfo(indx,info) ;
|
||||||
|
|
||||||
mLocalSharedDirs->getFileInfo(indx,info) ;
|
if(!real_hash.isNull())
|
||||||
|
{
|
||||||
|
info.hash = real_hash ;
|
||||||
|
info.transfer_info_flags |= RS_FILE_REQ_ENCRYPTED ;
|
||||||
|
}
|
||||||
|
|
||||||
if(!real_hash.isNull())
|
return true;
|
||||||
{
|
}
|
||||||
info.hash = real_hash ;
|
|
||||||
info.transfer_info_flags |= RS_FILE_REQ_ENCRYPTED ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hintflags & RS_FILE_HINTS_REMOTE)
|
if(hintflags & RS_FILE_HINTS_REMOTE)
|
||||||
{
|
{
|
||||||
NOT_IMPLEMENTED();
|
EntryIndex indx;
|
||||||
return false;
|
bool found = false ;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<mRemoteDirectories.size();++i)
|
||||||
|
if(mRemoteDirectories[i] != NULL && mRemoteDirectories[i]->searchHash(hash,indx))
|
||||||
|
{
|
||||||
|
TransferInfo ti ;
|
||||||
|
ti.peerId = mRemoteDirectories[i]->peerId();
|
||||||
|
|
||||||
|
info.hash = hash ;
|
||||||
|
info.peers.push_back(ti) ;
|
||||||
|
|
||||||
|
found = true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@
|
|||||||
* #define DEBUG_DWLQUEUE 1
|
* #define DEBUG_DWLQUEUE 1
|
||||||
*****/
|
*****/
|
||||||
|
|
||||||
static const int32_t SAVE_TRANSFERS_DELAY = 301 ; // save transfer progress every 301 seconds.
|
static const int32_t SAVE_TRANSFERS_DELAY = 301 ; // save transfer progress every 301 seconds.
|
||||||
static const int32_t INACTIVE_CHUNKS_CHECK_DELAY = 240 ; // time after which an inactive chunk is released
|
static const int32_t INACTIVE_CHUNKS_CHECK_DELAY = 240 ; // time after which an inactive chunk is released
|
||||||
static const int32_t MAX_TIME_INACTIVE_REQUEUED = 120 ; // time after which an inactive ftFileControl is bt-queued
|
static const int32_t MAX_TIME_INACTIVE_REQUEUED = 120 ; // time after which an inactive ftFileControl is bt-queued
|
||||||
|
|
||||||
static const int32_t FT_FILECONTROL_QUEUE_ADD_END = 0 ;
|
static const int32_t FT_FILECONTROL_QUEUE_ADD_END = 0 ;
|
||||||
@ -222,8 +222,8 @@ void ftController::data_tick()
|
|||||||
usleep(1*1000*1000); // 1 sec
|
usleep(1*1000*1000); // 1 sec
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController::run()";
|
//std::cerr << "ftController::run()";
|
||||||
std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
bool doPending = false;
|
bool doPending = false;
|
||||||
{
|
{
|
||||||
@ -234,14 +234,14 @@ void ftController::data_tick()
|
|||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
if(now > last_save_time + SAVE_TRANSFERS_DELAY)
|
if(now > last_save_time + SAVE_TRANSFERS_DELAY)
|
||||||
{
|
{
|
||||||
searchForDirectSources() ;
|
|
||||||
|
|
||||||
IndicateConfigChanged() ;
|
IndicateConfigChanged() ;
|
||||||
last_save_time = now ;
|
last_save_time = now ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(now > last_clean_time + INACTIVE_CHUNKS_CHECK_DELAY)
|
if(now > last_clean_time + INACTIVE_CHUNKS_CHECK_DELAY)
|
||||||
{
|
{
|
||||||
|
searchForDirectSources() ;
|
||||||
|
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
|
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
|
||||||
@ -280,12 +280,24 @@ void ftController::data_tick()
|
|||||||
|
|
||||||
void ftController::searchForDirectSources()
|
void ftController::searchForDirectSources()
|
||||||
{
|
{
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
std::cerr << "ftController::searchForDirectSources()" << std::endl;
|
||||||
|
#endif
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
if (!mSearch) return;
|
if (!mSearch)
|
||||||
|
{
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
std::cerr << " search module not available!" << std::endl;
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); ++it )
|
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); ++it )
|
||||||
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED )
|
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED )
|
||||||
{
|
{
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
std::cerr << " file " << it->first << ":" << std::endl;
|
||||||
|
#endif
|
||||||
FileInfo info ; // Info needs to be re-allocated each time, to start with a clear list of peers (it's not cleared down there)
|
FileInfo info ; // Info needs to be re-allocated each time, to start with a clear list of peers (it's not cleared down there)
|
||||||
|
|
||||||
if( mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info) )
|
if( mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info) )
|
||||||
@ -300,8 +312,19 @@ void ftController::searchForDirectSources()
|
|||||||
if( bAllowDirectDL )
|
if( bAllowDirectDL )
|
||||||
if( it->second->mTransfer->addFileSource(pit->peerId) ) /* if the sources don't exist already - add in */
|
if( it->second->mTransfer->addFileSource(pit->peerId) ) /* if the sources don't exist already - add in */
|
||||||
setPeerState( it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceType, pit->peerId) );
|
setPeerState( it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceType, pit->peerId) );
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
std::cerr << " found source " << pit->peerId << ", allowDirectDL=" << bAllowDirectDL << ". " << (bAllowDirectDL?"adding":"not adding") << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
else
|
||||||
|
std::cerr << " search returned empty.: " << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
else
|
||||||
|
std::cerr << " file " << it->first << ": state is " << it->second->mState << ": ignored." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftController::tickTransfers()
|
void ftController::tickTransfers()
|
||||||
@ -311,7 +334,7 @@ void ftController::tickTransfers()
|
|||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ticking transfers." << std::endl ;
|
// std::cerr << "ticking transfers." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
// Collect all non queued files.
|
// Collect all non queued files.
|
||||||
//
|
//
|
||||||
|
@ -160,7 +160,8 @@ void ftServer::SetupFtServer()
|
|||||||
void ftServer::connectToFileDatabase(p3FileDatabase *fdb)
|
void ftServer::connectToFileDatabase(p3FileDatabase *fdb)
|
||||||
{
|
{
|
||||||
mFileDatabase = fdb ;
|
mFileDatabase = fdb ;
|
||||||
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_REMOTE);
|
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_LOCAL); // due to a bug in addSearchModule, modules can only be added one by one. Using | between flags wont work.
|
||||||
|
mFtSearch->addSearchMode(fdb, RS_FILE_HINTS_REMOTE);
|
||||||
}
|
}
|
||||||
void ftServer::connectToTurtleRouter(p3turtle *fts)
|
void ftServer::connectToTurtleRouter(p3turtle *fts)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user