]> git.stg.codes - stg.git/blobdiff - projects/rscriptd/listener.cpp
Added note about waiting rscriptd until message queue becomes empty
[stg.git] / projects / rscriptd / listener.cpp
index 82dd631855d3272b5890b7c7309a207f9483dc8d..e9aacc19b0ad5b2d87ed4a9e5812d2fd1ea0bb7d 100644 (file)
 #include <sstream>
 #include <algorithm>
 
+#include "stg/scriptexecuter.h"
+#include "stg/locker.h"
+#include "stg/common.h"
 #include "listener.h"
-#include "script_executer.h"
-#include "stg_locker.h"
-#include "common.h"
 
 void InitEncrypt(BLOWFISH_CTX * ctx, const std::string & password);
 void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8);
@@ -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()