X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/d30add64d1fb2fd48ae5fe991166070684b0865f..eae461a00073f225f531b09c656bee2ed269bb7a:/projects/stargazer/user_impl.cpp?ds=sidebyside diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index eace1afb..7f2d5e0b 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -38,16 +38,16 @@ #include #include +#include "stg/users.h" +#include "stg/common.h" +#include "stg/scriptexecuter.h" +#include "stg/tariff.h" +#include "stg/tariffs.h" +#include "stg/admin.h" #include "user_impl.h" -#include "users.h" -#include "common.h" -#include "settings.h" -#include "script_executer.h" -#include "tariff.h" -#include "tariffs.h" -#include "admin.h" - -USER_IMPL::USER_IMPL(const SETTINGS * s, +#include "settings_impl.h" + +USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s, const STORE * st, const TARIFFS * t, const ADMIN * a, @@ -116,7 +116,7 @@ tariff = tariffs->GetNoTariff(); ips = StrToIPS("*"); deleted = false; lastWriteStat = stgTime + random() % settings->GetStatWritePeriod(); -lastWriteDeatiledStat = stgTime; +lastWriteDetailedStat = stgTime; property.tariffName.AddBeforeNotifier(&tariffNotifier); property.passive.AddBeforeNotifier(&passiveNotifier); @@ -194,7 +194,7 @@ connected = 0; deleted = u.deleted; lastWriteStat = u.lastWriteStat; -lastWriteDeatiledStat = u.lastWriteDeatiledStat; +lastWriteDetailedStat = u.lastWriteDetailedStat; settings = u.settings; @@ -628,7 +628,7 @@ if (!authorizedBy.empty()) { if (connected) { - lastActivityTime = *const_cast(&stgTime); + property.Stat().lastActivityTime = stgTime; } if (!connected && IsInetable()) { @@ -908,6 +908,30 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); currIP.DelAfterNotifier(n); } //----------------------------------------------------------------------------- +void USER_IMPL::AddConnectedBeforeNotifier(PROPERTY_NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +connected.AddBeforeNotifier(n); +} +//----------------------------------------------------------------------------- +void USER_IMPL::DelConnectedBeforeNotifier(PROPERTY_NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +connected.DelBeforeNotifier(n); +} +//----------------------------------------------------------------------------- +void USER_IMPL::AddConnectedAfterNotifier(PROPERTY_NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +connected.AddAfterNotifier(n); +} +//----------------------------------------------------------------------------- +void USER_IMPL::DelConnectedAfterNotifier(PROPERTY_NOTIFIER_BASE * n) +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); +connected.DelAfterNotifier(n); +} +//----------------------------------------------------------------------------- void USER_IMPL::OnAdd() { STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -981,7 +1005,7 @@ printfd(__FILE__, "USER::WriteDetailedStat() - size = %d\n", ts.size()); if (ts.size() && !disabledDetailStat) { - if (store->WriteDetailedStat(ts, lastWriteDeatiledStat, login)) + if (store->WriteDetailedStat(ts, lastWriteDetailedStat, login)) { printfd(__FILE__, "USER::WriteDetailStat() - failed to write current detail stat\n"); WriteServLog("Cannot write detail stat for user %s.", login.c_str()); @@ -991,12 +1015,12 @@ if (ts.size() && !disabledDetailStat) printfd(__FILE__, "USER::WriteDetailStat() - pushing detail stat to queue\n"); STG_LOCKER lock(&mutex, __FILE__, __LINE__); traffStatSaved.second.swap(ts); - traffStatSaved.first = lastWriteDeatiledStat; + traffStatSaved.first = lastWriteDetailedStat; } return -1; } } -lastWriteDeatiledStat = stgTime; +lastWriteDetailedStat = stgTime; return 0; } //----------------------------------------------------------------------------- @@ -1257,6 +1281,10 @@ while (it != messages.end()) ++it; } } + else + { + ++it; + } } } //-----------------------------------------------------------------------------