From 9e2edd39ec2cb1989f6261b1dc5e6c09373ee33d Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Fri, 24 Dec 2010 16:56:19 +0200 Subject: [PATCH] =?utf8?q?=D0=97=D0=BC=D1=96=D0=BC=D0=B5=D0=BD=D0=BE=20?= =?utf8?q?=D1=81=D0=BF=D0=BE=D1=81=D1=96=D0=B1=20=D0=B7=D0=B1=D0=B5=D1=80?= =?utf8?q?=D1=96=D0=B3=D0=B0=D0=BD=D0=BD=D1=8F=20TRAFF=5FSTATS=20=D0=BF?= =?utf8?q?=D1=96=D1=81=D0=BB=D1=8F=20=D0=BD=D0=B5=D0=B2=D0=B4=D0=B0=D0=BB?= =?utf8?q?=D0=BE=D0=B3=D0=BE=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- projects/stargazer/user.cpp | 25 ++++++++++++------------- projects/stargazer/user.h | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/projects/stargazer/user.cpp b/projects/stargazer/user.cpp index 989d11b5..48b8094c 100644 --- a/projects/stargazer/user.cpp +++ b/projects/stargazer/user.cpp @@ -940,22 +940,18 @@ Run(); //----------------------------------------------------------------------------- int USER::WriteDetailStat(bool hard) { -printfd(__FILE__, "USER::WriteDetailedStat() - queue size = %d\n", traffStatQueue.size()); +printfd(__FILE__, "USER::WriteDetailedStat() - saved size = %d\n", traffStatSaved.second.size()); -if (!traffStatQueue.empty()) +if (!traffStatSaved.second.empty()) { - std::list >::iterator it; - for (it = traffStatQueue.begin(); it != traffStatQueue.end(); ++it) + if (store->WriteDetailedStat(traffStatSaved.second, traffStatSaved.first, login)) { - if (store->WriteDetailedStat(it->second, it->first, login)) - { - printfd(__FILE__, "USER::WriteDetailStat() - failed to write detail stat from queue\n"); - WriteServLog("Cannot write detail stat from queue (of size %d recs) for user %s.", traffStatQueue.size(), login.c_str()); - WriteServLog("%s", store->GetStrError().c_str()); - return -1; - } - traffStatQueue.erase(it++); + printfd(__FILE__, "USER::WriteDetailStat() - failed to write detail stat from queue\n"); + WriteServLog("Cannot write detail stat from queue (of size %d recs) for user %s.", traffStatSaved.second.size(), login.c_str()); + WriteServLog("%s", store->GetStrError().c_str()); + return -1; } + traffStatSaved.second.erase(traffStatSaved.second.begin(), traffStatSaved.second.end()); } TRAFF_STAT ts; @@ -977,8 +973,11 @@ if (ts.size() && !disabledDetailStat) if (!hard) { printfd(__FILE__, "USER::WriteDetailStat() - pushing detail stat to queue\n"); - traffStatQueue.push_back(std::make_pair(lastWriteDeatiledStat, ts)); + STG_LOCKER lock(&mutex, __FILE__, __LINE__); + traffStatSaved.second.swap(ts); + traffStatSaved.first = lastWriteDeatiledStat; } + return -1; } } lastWriteDeatiledStat = stgTime; diff --git a/projects/stargazer/user.h b/projects/stargazer/user.h index 8e338463..392a121b 100644 --- a/projects/stargazer/user.h +++ b/projects/stargazer/user.h @@ -233,7 +233,7 @@ private: const TARIFF * tariff; TRAFF_STAT traffStat; - std::list > traffStatQueue; + std::pair traffStatSaved; const SETTINGS * settings; -- 2.44.2