diff options
author | Yana Chernysheva (GitHub) <59469418+ychernysheva@users.noreply.github.com> | 2021-02-04 23:24:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 16:24:55 -0500 |
commit | 8e0abd693cf549e4ccc1a73204370fa649a594bb (patch) | |
tree | 9343c99dd77000dce4b368b46b6df3d2541c37f5 /src | |
parent | a0bd7e37dbb142f6d370f54daad9c7d1b69b542c (diff) | |
download | sdl_core-8e0abd693cf549e4ccc1a73204370fa649a594bb.tar.gz |
Make correlation ID counter atomic (#3567)
* Make correlation_id_ counter atomic
Diffstat (limited to 'src')
-rw-r--r-- | src/components/application_manager/include/application_manager/application_manager_impl.h | 6 | ||||
-rw-r--r-- | src/components/application_manager/src/application_manager_impl.cc | 23 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 320d3df9ce..bedf63b954 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1615,9 +1615,9 @@ class ApplicationManagerImpl ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra mobile_v4_protocol_so_factory_; - static uint32_t mobile_corelation_id_; - static uint32_t corelation_id_; - static const uint32_t max_corelation_id_; + std::atomic_uint32_t mobile_correlation_id_; + std::atomic_uint32_t correlation_id_; + const uint32_t max_correlation_id_; std::unique_ptr<HMICapabilities> hmi_capabilities_; // The reason of HU shutdown diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 8c5932497a..dc56a0f84b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -145,10 +145,6 @@ struct PolicyAppIdComparator { const std::string& policy_app_id_; }; -uint32_t ApplicationManagerImpl::mobile_corelation_id_ = 0; -uint32_t ApplicationManagerImpl::corelation_id_ = 0; -const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; - namespace formatters = ns_smart_device_link::ns_json_handler::formatters; namespace jhs = ns_smart_device_link::ns_json_handler::strings; @@ -175,6 +171,9 @@ ApplicationManagerImpl::ApplicationManagerImpl( , policy_handler_(new policy::PolicyHandler(policy_settings, *this)) , protocol_handler_(NULL) , request_ctrl_(am_settings) + , mobile_correlation_id_(0) + , correlation_id_(0) + , max_correlation_id_(UINT_MAX) , hmi_capabilities_(new HMICapabilitiesImpl(*this)) , unregister_reason_( mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM) @@ -1364,23 +1363,23 @@ ApplicationManagerImpl::GetCloudAppConnectionStatus( } uint32_t ApplicationManagerImpl::GetNextMobileCorrelationID() { - if (mobile_corelation_id_ < max_corelation_id_) { - mobile_corelation_id_++; + if (mobile_correlation_id_ < max_correlation_id_) { + mobile_correlation_id_++; } else { - mobile_corelation_id_ = 0; + mobile_correlation_id_ = 0; } - return mobile_corelation_id_; + return mobile_correlation_id_; } uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { - if (corelation_id_ < max_corelation_id_) { - corelation_id_++; + if (correlation_id_ < max_correlation_id_) { + correlation_id_++; } else { - corelation_id_ = 0; + correlation_id_ = 0; } - return corelation_id_; + return correlation_id_; } bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) { |