X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/820288049b136a341da8815142ae44ac912b72ad..8c931ef33a414e473b19e773b445f4d30a0bfe2b:/projects/rscriptd/listener.cpp diff --git a/projects/rscriptd/listener.cpp b/projects/rscriptd/listener.cpp index f6d77c96..814eb1d8 100644 --- a/projects/rscriptd/listener.cpp +++ b/projects/rscriptd/listener.cpp @@ -162,9 +162,9 @@ return false; //----------------------------------------------------------------------------- void * LISTENER::Run(void * d) { -LISTENER * ia = static_cast(d); +LISTENER * listener = static_cast(d); -ia->Runner(); +listener->Runner(); return NULL; } @@ -183,9 +183,9 @@ receiverStopped = true; //----------------------------------------------------------------------------- void * LISTENER::RunProcessor(void * d) { -LISTENER * ia = static_cast(d); +LISTENER * listener = static_cast(d); -ia->ProcessorRunner(); +listener->ProcessorRunner(); return NULL; } @@ -215,8 +215,6 @@ if (listenSocket < 0) return true; } -printfd(__FILE__, "Port: %d\n", port); - struct sockaddr_in listenAddr; listenAddr.sin_family = AF_INET; listenAddr.sin_port = htons(port); @@ -250,7 +248,7 @@ RS_PACKET_HEADER packetHead; iov[0].iov_base = reinterpret_cast(&packetHead); iov[0].iov_len = sizeof(packetHead); iov[1].iov_base = buffer; -iov[1].iov_len = sizeof(buffer); +iov[1].iov_len = sizeof(buffer) - sizeof(packetHead); size_t dataLen = 0; while (dataLen < sizeof(buffer)) @@ -321,7 +319,7 @@ if (strncmp((char *)packetTail.magic, RS_ID, RS_MAGIC_LEN)) } std::stringstream params; -params << data.login << " " +params << "\"" << data.login << "\" " << inet_ntostring(data.ip) << " " << data.id << " " << (char *)packetTail.params; @@ -333,9 +331,10 @@ return false; //----------------------------------------------------------------------------- void LISTENER::ProcessPending() { -printfd(__FILE__, "Pending data size: %d\n", pending.size()); std::list::iterator it(pending.begin()); -while (it != pending.end()) +size_t count = 0; +printfd(__FILE__, "Pending: %d\n", pending.size()); +while (it != pending.end() && count < 256) { std::vector::iterator uit( std::lower_bound( @@ -375,10 +374,11 @@ while (it != pending.end()) users.erase(uit); } } - - STG_LOCKER lock(&mutex, __FILE__, __LINE__); - pending.erase(it++); + ++it; + ++count; } +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +pending.erase(pending.begin(), it); } //----------------------------------------------------------------------------- void LISTENER::ProcessTimeouts()