fixed threading issues in directory updater

This commit is contained in:
mr-alice 2016-08-05 22:37:40 +02:00
parent 067d4231ae
commit 43f4f5d2d9
3 changed files with 19 additions and 13 deletions

View file

@ -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]);