diff options
| author | Li Jin <dragon-fly@qq.com> | 2025-04-09 17:40:13 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2025-04-09 17:40:13 +0800 |
| commit | 9750786a5c03b5ce3ea22b240d1b3cd34990856b (patch) | |
| tree | e495e43245e1bacc86d33142af202613a82a40c1 /src/3rdParty/efsw/WatcherKqueue.cpp | |
| parent | 571fb952b99e580a0381f539885f8f175e2ec3b0 (diff) | |
| download | yuescript-9750786a5c03b5ce3ea22b240d1b3cd34990856b.tar.gz yuescript-9750786a5c03b5ce3ea22b240d1b3cd34990856b.tar.bz2 yuescript-9750786a5c03b5ce3ea22b240d1b3cd34990856b.zip | |
Updated efsw. Fixed issue #204.
Diffstat (limited to 'src/3rdParty/efsw/WatcherKqueue.cpp')
| -rw-r--r--[-rwxr-xr-x] | src/3rdParty/efsw/WatcherKqueue.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/3rdParty/efsw/WatcherKqueue.cpp b/src/3rdParty/efsw/WatcherKqueue.cpp index 441948a..424b989 100755..100644 --- a/src/3rdParty/efsw/WatcherKqueue.cpp +++ b/src/3rdParty/efsw/WatcherKqueue.cpp | |||
| @@ -139,7 +139,7 @@ void WatcherKqueue::addAll() { | |||
| 139 | void WatcherKqueue::removeAll() { | 139 | void WatcherKqueue::removeAll() { |
| 140 | efDEBUG( "removeAll(): Removing all child watchers\n" ); | 140 | efDEBUG( "removeAll(): Removing all child watchers\n" ); |
| 141 | 141 | ||
| 142 | std::list<WatchID> erase; | 142 | std::vector<WatchID> erase; |
| 143 | 143 | ||
| 144 | for ( WatchMap::iterator it = mWatches.begin(); it != mWatches.end(); it++ ) { | 144 | for ( WatchMap::iterator it = mWatches.begin(); it != mWatches.end(); it++ ) { |
| 145 | efDEBUG( "removeAll(): Removed child watcher %s\n", it->second->Directory.c_str() ); | 145 | efDEBUG( "removeAll(): Removed child watcher %s\n", it->second->Directory.c_str() ); |
| @@ -147,7 +147,7 @@ void WatcherKqueue::removeAll() { | |||
| 147 | erase.push_back( it->second->ID ); | 147 | erase.push_back( it->second->ID ); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | for ( std::list<WatchID>::iterator eit = erase.begin(); eit != erase.end(); eit++ ) { | 150 | for ( std::vector<WatchID>::iterator eit = erase.begin(); eit != erase.end(); eit++ ) { |
| 151 | removeWatch( *eit ); | 151 | removeWatch( *eit ); |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| @@ -354,7 +354,8 @@ void WatcherKqueue::watch() { | |||
| 354 | bool needScan = false; | 354 | bool needScan = false; |
| 355 | 355 | ||
| 356 | // Then we get the the events of the current folder | 356 | // Then we get the the events of the current folder |
| 357 | while ( ( nev = kevent( mKqueue, &mChangeList[0], mChangeListCount + 1, &event, 1, | 357 | while ( !mChangeList.empty() && |
| 358 | ( nev = kevent( mKqueue, mChangeList.data(), mChangeListCount + 1, &event, 1, | ||
| 358 | &mWatcher->mTimeOut ) ) != 0 ) { | 359 | &mWatcher->mTimeOut ) ) != 0 ) { |
| 359 | // An error ocurred? | 360 | // An error ocurred? |
| 360 | if ( nev == -1 ) { | 361 | if ( nev == -1 ) { |
| @@ -436,7 +437,6 @@ void WatcherKqueue::moveDirectory( std::string oldPath, std::string newPath, boo | |||
| 436 | 437 | ||
| 437 | WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener* watcher, | 438 | WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener* watcher, |
| 438 | bool recursive, WatcherKqueue* parent ) { | 439 | bool recursive, WatcherKqueue* parent ) { |
| 439 | static long s_fc = 0; | ||
| 440 | static bool s_ug = false; | 440 | static bool s_ug = false; |
| 441 | 441 | ||
| 442 | std::string dir( directory ); | 442 | std::string dir( directory ); |
| @@ -478,8 +478,6 @@ WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener | |||
| 478 | 478 | ||
| 479 | watch->addAll(); | 479 | watch->addAll(); |
| 480 | 480 | ||
| 481 | s_fc++; | ||
| 482 | |||
| 483 | // if failed to open the directory... erase the watcher | 481 | // if failed to open the directory... erase the watcher |
| 484 | if ( !watch->initOK() ) { | 482 | if ( !watch->initOK() ) { |
| 485 | int le = watch->lastErrno(); | 483 | int le = watch->lastErrno(); |
| @@ -502,9 +500,8 @@ WatchID WatcherKqueue::addWatch( const std::string& directory, FileWatchListener | |||
| 502 | } | 500 | } |
| 503 | } else { | 501 | } else { |
| 504 | if ( !s_ug ) { | 502 | if ( !s_ug ) { |
| 505 | efDEBUG( "Started using WatcherGeneric, reached file descriptors limit: %ld. Folders " | 503 | efDEBUG( "Started using WatcherGeneric, reached file descriptors limit: %ld.\n", |
| 506 | "added: %ld\n", | 504 | mWatcher->mFileDescriptorCount ); |
| 507 | mWatcher->mFileDescriptorCount, s_fc ); | ||
| 508 | s_ug = true; | 505 | s_ug = true; |
| 509 | } | 506 | } |
| 510 | 507 | ||
