X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/820288049b136a341da8815142ae44ac912b72ad..bf69e959b3e75cb3eb3748e93df9dcfe5b82aa17:/projects/rscriptd/listener.cpp diff --git a/projects/rscriptd/listener.cpp b/projects/rscriptd/listener.cpp index f6d77c96..aca5da44 100644 --- a/projects/rscriptd/listener.cpp +++ b/projects/rscriptd/listener.cpp @@ -333,9 +333,16 @@ return false; //----------------------------------------------------------------------------- void LISTENER::ProcessPending() { -printfd(__FILE__, "Pending data size: %d\n", pending.size()); -std::list::iterator it(pending.begin()); -while (it != pending.end()) +std::list localPending; + + { + STG_LOCKER lock(&mutex, __FILE__, __LINE__); + printfd(__FILE__, "Pending data size: %d\n", pending.size()); + localPending.swap(pending); + } + +std::list::iterator it(localPending.begin()); +while (it != localPending.end()) { std::vector::iterator uit( std::lower_bound( @@ -375,9 +382,7 @@ while (it != pending.end()) users.erase(uit); } } - - STG_LOCKER lock(&mutex, __FILE__, __LINE__); - pending.erase(it++); + ++it; } } //-----------------------------------------------------------------------------