From 1ed49c21260edc5b40aa2d0d4b8486bc1928f21b Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Fri, 21 Jan 2011 17:57:35 +0200 Subject: [PATCH] =?utf8?q?=D0=A3=D1=81=D1=83=D0=BD=D1=83=D1=82=D0=BE=20?= =?utf8?q?=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=D1=83=20race=20condit?= =?utf8?q?ions=20=D1=83=20rscriptd?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- projects/rscriptd/listener.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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; } } //----------------------------------------------------------------------------- -- 2.44.2