diff --git a/libretroshare/src/file_sharing/directory_updater.cc b/libretroshare/src/file_sharing/directory_updater.cc index b4ebfb0f5..bccae26cf 100644 --- a/libretroshare/src/file_sharing/directory_updater.cc +++ b/libretroshare/src/file_sharing/directory_updater.cc @@ -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() diff --git a/libretroshare/src/file_sharing/hash_cache.cc b/libretroshare/src/file_sharing/hash_cache.cc index eb86813b3..58ca5d80a 100644 --- a/libretroshare/src/file_sharing/hash_cache.cc +++ b/libretroshare/src/file_sharing/hash_cache.cc @@ -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]); diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 597c9292e..302bc778d 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -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; }