X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/cae8a878811382886af21000064ff659309f7e4c..f5bfdf06e2e8f2e6f479cc6b477a6c7c4a69f965:/projects/rscriptd/listener.cpp

diff --git a/projects/rscriptd/listener.cpp b/projects/rscriptd/listener.cpp
index 82dd6318..814eb1d8 100644
--- a/projects/rscriptd/listener.cpp
+++ b/projects/rscriptd/listener.cpp
@@ -331,16 +331,10 @@ return false;
 //-----------------------------------------------------------------------------
 void LISTENER::ProcessPending()
 {
-std::list<PendingData> localPending;
-
-    {
-    STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-    printfd(__FILE__, "Pending data size: %d\n", pending.size());
-    localPending.swap(pending);
-    }
-
-std::list<PendingData>::iterator it(localPending.begin());
-while (it != localPending.end())
+std::list<PendingData>::iterator it(pending.begin());
+size_t count = 0;
+printfd(__FILE__, "Pending: %d\n", pending.size());
+while (it != pending.end() && count < 256)
     {
     std::vector<AliveData>::iterator uit(
             std::lower_bound(
@@ -381,7 +375,10 @@ while (it != localPending.end())
             }
         }
     ++it;
+    ++count;
     }
+STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+pending.erase(pending.begin(), it);
 }
 //-----------------------------------------------------------------------------
 void LISTENER::ProcessTimeouts()