From: Maxim Mamontov Date: Mon, 6 Dec 2010 14:55:20 +0000 (+0200) Subject: Исправлена работа конструктора копирования класса USER. Убраны участки X-Git-Tag: 2.407-rc3~343 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/bc4929f4d2f051277f116d6d582ccdb371f27595?hp=1bf5ae378079e212f6918d09d87dec5420a0d6ec Исправлена работа конструктора копирования класса USER. Убраны участки "мертвого" кода. Уменьшена область видимости некоторых переменных. --- diff --git a/projects/stargazer/user.cpp b/projects/stargazer/user.cpp index 2db51411..3e3ee5af 100644 --- a/projects/stargazer/user.cpp +++ b/projects/stargazer/user.cpp @@ -192,13 +192,10 @@ if (&u == this) return; connected = 0; -//traffStatInUse = 0; ipIndex = u.ipIndex; deleted = u.deleted; -/*traffStat = &traffStatInternal[traffStatInUse % 2]; -traffStatToWrite = &traffStatInternal[(traffStatInUse +1) % 2];*/ lastWriteStat = u.lastWriteStat; lastWriteDeatiledStat = u.lastWriteDeatiledStat; @@ -215,6 +212,46 @@ lastScanMessages = 0; writeFreeMbTraffCost = settings->GetWriteFreeMbTraffCost(); +// Conf +password = u.password.ConstData(); +passive = u.passive.ConstData(); +disabled = u.disabled.ConstData(); +disabledDetailStat = u.disabledDetailStat.ConstData(); +alwaysOnline = u.alwaysOnline.ConstData(); +tariffName = u.tariffName.ConstData(); +nextTariff = u.nextTariff.ConstData(); +address = u.address.ConstData(); +phone = u.phone.ConstData(); +email = u.email.ConstData(); +note = u.note.ConstData(); +realName = u.realName.ConstData(); +group = u.group.ConstData(); +credit = u.credit.ConstData(); +nextTariff = u.nextTariff.ConstData(); +userdata0 = u.userdata0.ConstData(); +userdata1 = u.userdata1.ConstData(); +userdata2 = u.userdata2.ConstData(); +userdata3 = u.userdata3.ConstData(); +userdata4 = u.userdata4.ConstData(); +userdata5 = u.userdata5.ConstData(); +userdata6 = u.userdata6.ConstData(); +userdata7 = u.userdata7.ConstData(); +userdata8 = u.userdata8.ConstData(); +userdata9 = u.userdata9.ConstData(); + +creditExpire = u.creditExpire.ConstData(); +ips = u.ips.ConstData(); + +// Stats +up = u.up.ConstData(); +down = u.down.ConstData(); +cash = u.cash.ConstData(); +freeMb = u.freeMb.ConstData(); +lastCashAdd = u.lastCashAdd.ConstData(); +lastCashAddTime = u.lastCashAddTime.ConstData(); +passiveTime = u.passiveTime.ConstData(); +lastActivityTime = u.lastActivityTime.ConstData(); + pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); @@ -567,10 +604,6 @@ if (store->WriteUserConnect(login, currIP)) if (!fakeConnect) lastIPForDisconnect = currIP; - -//printfd(__FILE__, "Connect. user name \'%s\' ip=%s\n", login.c_str(), inet_ntostring(currIP).c_str()); -/*if (settings->GetLogUserConnectDisconnect()) - WriteServLog("User \'%s\', %s: Connect.", login.c_str(), inet_ntostring(currIP).c_str());*/ } //----------------------------------------------------------------------------- void USER::Disconnect(bool fakeDisconnect, const std::string & reason) @@ -626,10 +659,6 @@ if (store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload, WriteServLog("%s", store->GetStrError().c_str()); } -//printfd(__FILE__, "Disconnect. User name \'%s\' ip=%s reason: '%s'\n", login.c_str(), inet_ntostring(lastIPForDisconnect).c_str(), reason.c_str()); -/*if (settings->GetLogUserConnectDisconnect()) - WriteServLog("User \'%s\', %s: Disconnect.", login.c_str(), inet_ntostring(lastIPForDisconnect).c_str());*/ - if (!fakeDisconnect) lastIPForDisconnect = 0; @@ -1029,29 +1058,8 @@ else Run(); } //----------------------------------------------------------------------------- -/*void USER::ResetDetailStat() -{ -STG_LOCKER lock(&mutex, __FILE__, __LINE__); - -traffStatToWrite->erase(traffStatToWrite->begin(), traffStatToWrite->end()); -}*/ -//----------------------------------------------------------------------------- int USER::WriteDetailStat(bool hard) { -/*STG_LOCKER lock(&mutex, __FILE__, __LINE__); - -printfd(__FILE__, "USER::WriteDetailedStat(): size = %d\n", traffStatToWrite->size()); - -if (traffStatToWrite->size() && !disabledDetailStat) - { - if (store->WriteDetailedStat(traffStatToWrite, lastWriteDeatiledStat, login)) - { - WriteServLog("Cannot write detail stat for user %s.", login.c_str()); - WriteServLog("%s", store->GetStrError().c_str()); - } - } -lastWriteDeatiledStat = lastSwapDeatiledStat; -return 0;*/ printfd(__FILE__, "USER::WriteDetailedStat() - queue size = %d\n", traffStatQueue.size()); if (!traffStatQueue.empty()) @@ -1097,17 +1105,6 @@ lastWriteDeatiledStat = stgTime; return 0; } //----------------------------------------------------------------------------- -/*int USER::SwapDetailStat() -{ -STG_LOCKER lock(&mutex, __FILE__, __LINE__); - -lastSwapDeatiledStat = stgTime; -traffStatToWrite = &traffStatInternal[traffStatInUse % 2]; -traffStat = &traffStatInternal[++traffStatInUse % 2]; - -return 0; -}*/ -//----------------------------------------------------------------------------- double USER::GetPassiveTimePart() const { STG_LOCKER lock(&mutex, __FILE__, __LINE__); diff --git a/projects/stargazer/user.h b/projects/stargazer/user.h index 8b35dbec..3631d900 100644 --- a/projects/stargazer/user.h +++ b/projects/stargazer/user.h @@ -144,8 +144,6 @@ public: void ResetPassiveTime() { passiveTime = 0; } void SetPassiveTimeAsNewUser(); - /*void ResetDetailStat(); - int SwapDetailStat();*/ int WriteDetailStat(bool hard = false); const TARIFF * GetTariff() const { return tariff; } @@ -235,11 +233,6 @@ private: const TARIFFS * tariffs; const TARIFF * tariff; - /*map traffStatInternal[2]; - map * traffStat; - map * traffStatToWrite; - int traffStatInUse;*/ - TRAFF_STAT traffStat; std::list > traffStatQueue; diff --git a/projects/stargazer/users.cpp b/projects/stargazer/users.cpp index 9a219be6..068193ef 100644 --- a/projects/stargazer/users.cpp +++ b/projects/stargazer/users.cpp @@ -352,9 +352,6 @@ return NULL; //----------------------------------------------------------------------------- void USERS::NewMinute(const struct tm * t) { -int usersCnt = 0; -list::iterator usr; - //Write traff, reset session traff. Fake disconnect-connect if (t->tm_hour == 23 && t->tm_min == 59) { @@ -365,11 +362,10 @@ if (t->tm_hour == 23 && t->tm_min == 59) if (TimeToWriteDetailStat(t)) { //printfd(__FILE__, "USER::WriteInetStat\n"); - //for_each(users.begin(), users.end(), mem_fun_ref(&USER::SwapDetailStat)); - usersCnt = 0; + int usersCnt = 0; // ðÉÛÅÍ ÀÚÅÒÏ× ÞÁÓÔÑÍÉ. ÷ ÐÅÒÅÒÙ×ÁÈ ×ÙÚÙ×ÁÅÍ USER::Run - usr = users.begin(); + list::iterator usr = users.begin(); while (usr != users.end()) { usersCnt++; @@ -378,8 +374,6 @@ if (TimeToWriteDetailStat(t)) if (usersCnt % 10 == 0) for_each(users.begin(), users.end(), mem_fun_ref(&USER::Run)); } - - //for_each(users.begin(), users.end(), mem_fun_ref(&USER::ResetDetailStat)); } RealDelUser(); @@ -495,7 +489,6 @@ if (isRunning) printfd(__FILE__, "Before USERS::Run()\n"); for_each(users.begin(), users.end(), mem_fun_ref(&USER::Run)); -//for_each(users.begin(), users.end(), mem_fun_ref(&USER::SwapDetailStat)); for_each(users.begin(), users.end(), bind2nd(mem_fun_ref(&USER::WriteDetailStat), true)); for_each(users.begin(), users.end(), mem_fun_ref(&USER::WriteStat)); for_each(users.begin(), users.end(), mem_fun_ref(&USER::WriteConf)); @@ -753,16 +746,3 @@ switch (statTime) } return false; } -//----------------------------------------------------------------------------- -/*int USERS::SendMessage(const string & login, - time_t sndTtime, - time_t showTime, - char type, - const string & text) const -{ -return 0; -}*/ -//----------------------------------------------------------------------------- - - -