From: Maxim Mamontov Date: Sat, 20 Aug 2016 10:15:52 +0000 (+0300) Subject: Fix tariff name in OnConnect during reconnect on tariff change. X-Git-Tag: 2.409~111^2 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/d6619016c144071dab0b4b32bdea6d0ede9e32d1?ds=sidebyside;hp=-c Fix tariff name in OnConnect during reconnect on tariff change. --- d6619016c144071dab0b4b32bdea6d0ede9e32d1 diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index 5d505307..d7bc8ea2 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -1494,13 +1494,18 @@ else if (!oldValue && newValue && user->IsInetable()) //----------------------------------------------------------------------------- void CHG_TARIFF_NOTIFIER::Notify(const std::string &, const std::string & newTariff) { +STG_LOCKER lock(&user->mutex); if (user->settings->GetReconnectOnTariffChange() && user->connected) user->Disconnect(false, "Change tariff"); user->tariff = user->tariffs->FindByName(newTariff); if (user->settings->GetReconnectOnTariffChange() && !user->authorizedBy.empty() && user->IsInetable()) + { + // This notifier gets called *before* changing the tariff, and in Connect we want to see new tariff name. + user->property.Conf().tariffName = newTariff; user->Connect(false); + } } //----------------------------------------------------------------------------- void CHG_CASH_NOTIFIER::Notify(const double & oldCash, const double & newCash)