X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/cae8a878811382886af21000064ff659309f7e4c..1911f68bb36127dfecfcd0fd71726069837053a0:/projects/rscriptd/listener.cpp diff --git a/projects/rscriptd/listener.cpp b/projects/rscriptd/listener.cpp index 82dd6318..39e590b6 100644 --- a/projects/rscriptd/listener.cpp +++ b/projects/rscriptd/listener.cpp @@ -33,10 +33,10 @@ #include #include +#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 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::list::iterator it(pending.begin()); +size_t count = 0; +printfd(__FILE__, "Pending: %d\n", pending.size()); +while (it != pending.end() && count < 256) { std::vector::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() @@ -413,7 +410,7 @@ bool LISTENER::Connect(const UserData & data) const printfd(__FILE__, "Connect %s\n", data.login.c_str()); if (access(scriptOnConnect.c_str(), X_OK) == 0) { - if (ScriptExec(scriptOnConnect + " " + data.params)) + if (ScriptExec((scriptOnConnect + " " + data.params).c_str())) { WriteServLog("Script %s cannot be executed for an unknown reason.", scriptOnConnect.c_str()); return true; @@ -432,7 +429,7 @@ bool LISTENER::Disconnect(const UserData & data) const printfd(__FILE__, "Disconnect %s\n", data.login.c_str()); if (access(scriptOnDisconnect.c_str(), X_OK) == 0) { - if (ScriptExec(scriptOnDisconnect + " " + data.params)) + if (ScriptExec((scriptOnDisconnect + " " + data.params).c_str())) { WriteServLog("Script %s cannot be executed for an unknown reson.", scriptOnDisconnect.c_str()); return true;