X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..760c0ea6e896fd918bfd096a06e334e769041db2:/projects/stargazer/traffcounter.cpp?ds=inline diff --git a/projects/stargazer/traffcounter.cpp b/projects/stargazer/traffcounter.cpp index 54014167..e9c143ec 100644 --- a/projects/stargazer/traffcounter.cpp +++ b/projects/stargazer/traffcounter.cpp @@ -287,7 +287,7 @@ int oldIp2packetsSize = ip2packets.size(); pp_iter pi; pi = packets.begin(); std::map newPackets; -std::multimap newIP2Packets; +ip2packets.erase(ip2packets.begin(), ip2packets.end()); while (pi != packets.end()) { //Flushing @@ -388,14 +388,13 @@ while (pi != packets.end()) pair res = newPackets.insert(*pi); if (res.second) { - newIP2Packets.insert(make_pair(pi->first.GetSrcIP(), res.first)); - newIP2Packets.insert(make_pair(pi->first.GetDstIP(), res.first)); + ip2packets.insert(make_pair(pi->first.GetSrcIP(), res.first)); + ip2packets.insert(make_pair(pi->first.GetDstIP(), res.first)); } } ++pi; } swap(packets, newPackets); -swap(ip2packets, newIP2Packets); printfd(__FILE__, "FlushAndRemove() packets: %d(rem %d) ip2packets: %d(rem %d)\n", packets.size(), oldPacketsSize - packets.size(), @@ -410,7 +409,7 @@ printfd(__FILE__, "AddUser: %s\n", user->GetLogin().c_str()); uint32_t uip = user->GetCurrIP(); pair pi; -STG_LOCKER(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex, __FILE__, __LINE__); // Find all packets with IP belongs to this user pi = ip2packets.equal_range(uip); @@ -447,7 +446,7 @@ void TRAFFCOUNTER::DelUser(uint32_t uip) printfd(__FILE__, "DelUser: %s \n", inet_ntostring(uip).c_str()); pair pi; -STG_LOCKER(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex, __FILE__, __LINE__); pi = ip2packets.equal_range(uip); while (pi.first != pi.second) @@ -699,6 +698,7 @@ while (fgets(str, 1023, f)) if (r != 3) { WriteServLog("Error in file %s. There must be 3 parameters. Line %d.", rulesFileName.c_str(), lineNumber); + fclose(f); return true; } @@ -721,6 +721,7 @@ while (fgets(str, 1023, f)) { WriteServLog("Error in file %s. Line %d.", rulesFileName.c_str(), lineNumber); + fclose(f); return true; } @@ -728,6 +729,7 @@ while (fgets(str, 1023, f)) { WriteServLog("Error in file %s. Error in adress. Line %d.", rulesFileName.c_str(), lineNumber); + fclose(f); return true; } if (!test)