X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/c3d4d096451b5c683492e81574b302e5486950e1..cd22a6554a8c6d917306304aeaf5d2b7a9d99ae4:/projects/stargazer/users_impl.cpp diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index d66456af..70a079bf 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -51,29 +51,18 @@ extern volatile time_t stgTime; //#define USERS_DEBUG 1 //----------------------------------------------------------------------------- -USERS_IMPL::USERS_IMPL(SETTINGS_IMPL * s, STORE * st, TARIFFS * t, const ADMIN * sa) - : USERS(), - users(), - usersToDelete(), - /*userIPNotifiersBefore(), - userIPNotifiersAfter(),*/ - ipIndex(), - loginIndex(), - settings(s), +USERS_IMPL::USERS_IMPL(SETTINGS_IMPL * s, STORE * st, + TARIFFS * t, SERVICES & svcs, + const ADMIN * sa) + : settings(s), tariffs(t), + m_services(svcs), store(st), sysAdmin(sa), WriteServLog(GetStgLogger()), nonstop(false), isRunning(false), - mutex(), - thread(), - handle(0), - searchDescriptors(), - onAddNotifiers(), - onDelNotifiers(), - onAddNotifiersImpl(), - onDelNotifiersImpl() + handle(0) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -126,6 +115,13 @@ if (FindByNameNonLock(login, &u)) return 0; } //----------------------------------------------------------------------------- +bool USERS_IMPL::Exists(const std::string & login) const +{ +STG_LOCKER lock(&mutex); +const std::map::const_iterator iter(loginIndex.find(login)); +return iter != loginIndex.end(); +} +//----------------------------------------------------------------------------- bool USERS_IMPL::TariffInUse(const std::string & tariffName) const { STG_LOCKER lock(&mutex); @@ -164,7 +160,7 @@ if (store->AddUser(login)) } ////// -USER_IMPL u(settings, store, tariffs, sysAdmin, this); +USER_IMPL u(settings, store, tariffs, sysAdmin, this, m_services); /*struct tm * tms; time_t t = stgTime; @@ -348,9 +344,10 @@ if (store->GetUsersList(&usersList) < 0) user_iter ui; +unsigned errors = 0; for (unsigned int i = 0; i < usersList.size(); i++) { - USER_IMPL u(settings, store, tariffs, sysAdmin, this); + USER_IMPL u(settings, store, tariffs, sysAdmin, this, m_services); u.SetLogin(usersList[i]); users.push_front(u); @@ -358,13 +355,25 @@ for (unsigned int i = 0; i < usersList.size(); i++) AddUserIntoIndexes(ui); - if (ui->ReadConf() < 0) - return -1; + if (settings->GetStopOnError()) + { + if (ui->ReadConf() < 0) + return -1; - if (ui->ReadStat() < 0) - return -1; + if (ui->ReadStat() < 0) + return -1; + } else + { + if (ui->ReadConf() < 0) + errors++; + + if (ui->ReadStat() < 0) + errors++; + } } +if (errors > 0) + return -1; return 0; } //----------------------------------------------------------------------------- @@ -514,6 +523,7 @@ else } std::for_each(users.begin(), users.end(), std::mem_fun_ref(&USER_IMPL::ProcessDailyFee)); +std::for_each(users.begin(), users.end(), std::mem_fun_ref(&USER_IMPL::ProcessServices)); if (settings->GetDayFeeIsLastDay()) {