]> git.stg.codes - stg.git/commitdiff
Fix tariff name in OnConnect during reconnect on tariff change.
authorMaxim Mamontov <faust.madf@gmail.com>
Sat, 20 Aug 2016 10:15:52 +0000 (13:15 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Sat, 20 Aug 2016 10:15:52 +0000 (13:15 +0300)
projects/stargazer/user_impl.cpp

index 5d505307a72302bbddccbe92be280aefdea592a7..d7bc8ea254bd37a6308b6f26a897d1a5a9259193 100644 (file)
@@ -1494,13 +1494,18 @@ else if (!oldValue && newValue && user->IsInetable())
 //-----------------------------------------------------------------------------
 void CHG_TARIFF_NOTIFIER::Notify(const std::string &, const std::string & newTariff)
 {
 //-----------------------------------------------------------------------------
 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())
 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);
     user->Connect(false);
+    }
 }
 //-----------------------------------------------------------------------------
 void CHG_CASH_NOTIFIER::Notify(const double & oldCash, const double & newCash)
 }
 //-----------------------------------------------------------------------------
 void CHG_CASH_NOTIFIER::Notify(const double & oldCash, const double & newCash)