mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed threading issues in directory updater
This commit is contained in:
parent
067d4231ae
commit
43f4f5d2d9
@ -5,7 +5,7 @@
|
||||
|
||||
#define DEBUG_LOCAL_DIR_UPDATER 1
|
||||
|
||||
static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 10 ; // 10 seconds for testing. Should be much more!!
|
||||
static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 100 ; // 10 seconds for testing. Should be much more!!
|
||||
|
||||
void RemoteDirectoryUpdater::tick()
|
||||
{
|
||||
@ -27,6 +27,8 @@ void LocalDirectoryUpdater::data_tick()
|
||||
sweepSharedDirectories() ;
|
||||
mLastSweepTime = now;
|
||||
}
|
||||
else
|
||||
usleep(10*1000*1000);
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::sweepSharedDirectories()
|
||||
|
@ -19,7 +19,15 @@ void HashStorage::data_tick()
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
|
||||
if(mFilesToHash.empty())
|
||||
{
|
||||
std::cerr << "Stopping hashing thread." << std::endl;
|
||||
shutdown();
|
||||
mRunning = false ;
|
||||
std::cerr << "done." << std::endl;
|
||||
|
||||
usleep(2*1000*1000); // when no files to hash, just wait for 2 secs. This avoids a dramatic loop.
|
||||
return ;
|
||||
}
|
||||
|
||||
job = mFilesToHash.begin()->second ;
|
||||
|
||||
@ -33,14 +41,6 @@ void HashStorage::data_tick()
|
||||
|
||||
mFilesToHash.erase(mFilesToHash.begin()) ;
|
||||
|
||||
if(mFilesToHash.empty())
|
||||
{
|
||||
std::cerr << "Stopping hashing thread." << std::endl;
|
||||
shutdown();
|
||||
mRunning = false ;
|
||||
std::cerr << "done." << std::endl;
|
||||
}
|
||||
|
||||
// store the result
|
||||
|
||||
HashStorageInfo& info(mFiles[job.full_path]);
|
||||
|
@ -31,8 +31,6 @@ p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
||||
mLocalDirWatcher = new LocalDirectoryUpdater(mHashCache,mLocalSharedDirs) ;
|
||||
mRemoteDirWatcher = NULL; // not used yet
|
||||
|
||||
mLocalDirWatcher->start();
|
||||
|
||||
mUpdateFlags = P3FILELISTS_UPDATE_FLAG_NOTHING_CHANGED ;
|
||||
}
|
||||
|
||||
@ -101,15 +99,21 @@ int p3FileDatabase::tick()
|
||||
void p3FileDatabase::startThreads()
|
||||
{
|
||||
std::cerr << "Starting hash cache thread..." ;
|
||||
|
||||
mHashCache->start();
|
||||
std::cerr << "Done." << std::endl;
|
||||
|
||||
std::cerr << "Starting directory watcher thread..." ;
|
||||
mLocalDirWatcher->start();
|
||||
std::cerr << "Done." << std::endl;
|
||||
}
|
||||
void p3FileDatabase::stopThreads()
|
||||
{
|
||||
std::cerr << "Stopping hash cache thread..." ; std::cerr.flush() ;
|
||||
|
||||
mHashCache->fullstop();
|
||||
std::cerr << "Done." << std::endl;
|
||||
|
||||
std::cerr << "Stopping directory watcher thread..." ; std::cerr.flush() ;
|
||||
mLocalDirWatcher->fullstop();
|
||||
std::cerr << "Done." << std::endl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user