From 9750786a5c03b5ce3ea22b240d1b3cd34990856b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 9 Apr 2025 17:40:13 +0800 Subject: Updated efsw. Fixed issue #204. --- src/3rdParty/efsw/WatcherKqueue.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) mode change 100755 => 100644 src/3rdParty/efsw/WatcherKqueue.cpp (limited to 'src/3rdParty/efsw/WatcherKqueue.cpp') diff --git a/src/3rdParty/efsw/WatcherKqueue.cpp b/src/3rdParty/efsw/WatcherKqueue.cpp old mode 100755 new mode 100644 index 441948a..424b989 --- a/src/3rdParty/efsw/WatcherKqueue.cpp +++ b/src/3rdParty/efsw/WatcherKqueue.cpp @@ -139,7 +139,7 @@ void WatcherKqueue::addAll() { void WatcherKqueue::removeAll() { efDEBUG( "removeAll(): Removing all child watchers\n" ); - std::list erase; + std::vector erase; for ( WatchMap::iterator it = mWatches.begin(); it != mWatches.end(); it++ ) { efDEBUG( "removeAll(): Removed child watcher %s\n", it->second->Directory.c_str() ); @@ -147,7 +147,7 @@ void WatcherKqueue::removeAll() { erase.push_back( it->second->ID ); } - for ( std::list::iterator eit = erase.begin(); eit != erase.end(); eit++ ) { + for ( std::vector::iterator eit = erase.begin(); eit != erase.end(); eit++ ) { removeWatch( *eit ); } } @@ -354,7 +354,8 @@ void WatcherKqueue::watch() { bool needScan = false; // Then we get the the events of the current folder - while ( ( nev = kevent( mKqueue, &mChangeList[0], mChangeListCount + 1, &event, 1, + while ( !mChangeList.empty() && + ( nev = kevent( mKqueue, mChangeList.data(), mChangeListCount + 1, &event, 1, &mWatcher->mTimeOut ) ) != 0 ) { // An error ocurred? if ( nev == -1 ) { @@ -436,7 +437,6 @@ void WatcherKqueue::moveDirectory( std::string oldPath, std::string newPath, boo WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive, WatcherKqueue* parent ) { - static long s_fc = 0; static bool s_ug = false; std::string dir( directory ); @@ -478,8 +478,6 @@ WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener watch->addAll(); - s_fc++; - // if failed to open the directory... erase the watcher if ( !watch->initOK() ) { int le = watch->lastErrno(); @@ -502,9 +500,8 @@ WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener } } else { if ( !s_ug ) { - efDEBUG( "Started using WatcherGeneric, reached file descriptors limit: %ld. Folders " - "added: %ld\n", - mWatcher->mFileDescriptorCount, s_fc ); + efDEBUG( "Started using WatcherGeneric, reached file descriptors limit: %ld.\n", + mWatcher->mFileDescriptorCount ); s_ug = true; } -- cgit v1.2.3-55-g6feb