diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2018-11-26 15:23:24 -0500 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2018-11-26 15:32:11 -0500 |
commit | 095f9ce3a935ed3a43041b44bf443da8047b1757 (patch) | |
tree | 3af0cd7106cc12bb8dcd09b236b7a2d22084e479 /src/components | |
parent | e310e85c5cea102aca3d477f6de93c7ee3ce560f (diff) | |
download | sdl_core-095f9ce3a935ed3a43041b44bf443da8047b1757.tar.gz |
Fix issues with retry sequence
Also address review comments and fix build issues.
Diffstat (limited to 'src/components')
6 files changed, 34 insertions, 16 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index bfe7adec11..1704251c17 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -145,7 +145,7 @@ void SDLActivateAppRequest::Run() { const uint32_t application_id = app_id(); ApplicationConstSharedPtr app_to_activate = - application_manager_.application_by_hmi_app(application_id); + application_manager_.application(application_id); if (!app_to_activate) { LOG4CXX_WARN( diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 64be323145..379e73bce9 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1187,7 +1187,7 @@ const std::string& ApplicationImpl::cloud_app_certificate() const { bool ApplicationImpl::is_cloud_app() const { return !endpoint_.empty() && hybrid_app_preference_ != - hmi_apis::Common_CloudConnectionStatus::MOBILE; + mobile_apis::HybridAppPreference::MOBILE; } void ApplicationImpl::set_cloud_app_endpoint(const std::string& endpoint) { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 79bd00b37d..e9a45001c7 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -645,7 +645,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( // Set cloud app parameters application->set_cloud_app_endpoint((*it)->cloud_app_endpoint()); application->set_cloud_app_certificate((*it)->cloud_app_certificate()); - application->set_cloud_app_auth_token((*it)->cloud_app_authtoken()); + application->set_cloud_app_auth_token((*it)->cloud_app_auth_token()); application->set_cloud_app_transport_type( (*it)->cloud_app_transport_type()); application->set_hybrid_app_preference((*it)->hybrid_app_preference()); diff --git a/src/components/include/transport_manager/transport_adapter/device.h b/src/components/include/transport_manager/transport_adapter/device.h index 448df9668a..17fd6b6950 100644 --- a/src/components/include/transport_manager/transport_adapter/device.h +++ b/src/components/include/transport_manager/transport_adapter/device.h @@ -58,7 +58,9 @@ class Device { Device(const std::string& name, const DeviceUID& unique_device_id) : name_(name) , unique_device_id_(unique_device_id) - , keep_on_disconnect_(false) {} + , keep_on_disconnect_(false) + , status_(ConnectionStatus::PENDING) + , retry_count_(0) {} /** * Constructor for creating device supporting transport switch @@ -73,7 +75,9 @@ class Device { : name_(name) , unique_device_id_(unique_device_id) , transport_switch_id_(transport_switch_id) - , keep_on_disconnect_(false) {} + , keep_on_disconnect_(false) + , status_(ConnectionStatus::PENDING) + , retry_count_(0) {} /** * @brief Destructor. diff --git a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h index e06537677a..ba50025cda 100644 --- a/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h +++ b/src/components/transport_manager/include/transport_manager/transport_adapter/transport_adapter_impl.h @@ -553,6 +553,7 @@ class TransportAdapterImpl : public TransportAdapter, TransportAdapter::Error ConnectDevice(DeviceSptr device); void RetryConnection(); + DeviceUID GetNextRetryDevice(); /** * @brief Remove specified device @@ -616,6 +617,7 @@ class TransportAdapterImpl : public TransportAdapter, ConnectionMap connections_; std::queue<std::pair<TimerSPtr, DeviceUID> > retry_timer_pool_; + sync_primitives::RecursiveLock retry_timer_pool_lock_; /** * @brief Mutex restricting access to connections map. diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index b73f3140d3..02eb721238 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -239,17 +239,6 @@ TransportAdapter::Error TransportAdapterImpl::Connect( return err; } -void TransportAdapterImpl::RetryConnection() { - if (retry_timer_pool_.empty()) { - LOG4CXX_ERROR(logger_, - "Unable to find timer, ignoring RetryConnection request"); - return; - } - const DeviceUID device_id = retry_timer_pool_.front().second; - retry_timer_pool_.pop(); - ConnectDevice(device_id); -} - TransportAdapter::Error TransportAdapterImpl::ConnectDevice( const DeviceUID& device_handle) { LOG4CXX_TRACE(logger_, "enter with device_handle: " << &device_handle); @@ -276,6 +265,7 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( "RetryConnectionTimer", new timer::TimerTaskImpl<TransportAdapterImpl>( this, &TransportAdapterImpl::RetryConnection))); + sync_primitives::AutoLock locker(retry_timer_pool_lock_); retry_timer_pool_.push(std::make_pair(retry_timer, device_handle)); retry_timer->Start(get_settings().cloud_app_retry_timeout(), timer::kSingleShot); @@ -290,6 +280,28 @@ TransportAdapter::Error TransportAdapterImpl::ConnectDevice( } } +void TransportAdapterImpl::RetryConnection() { + const DeviceUID device_id = GetNextRetryDevice(); + if (device_id.empty()) { + LOG4CXX_ERROR(logger_, + "Unable to find timer, ignoring RetryConnection request"); + return; + } + ConnectDevice(device_id); +} + +DeviceUID TransportAdapterImpl::GetNextRetryDevice() { + sync_primitives::AutoLock locker(retry_timer_pool_lock_); + while (!retry_timer_pool_.empty()) { + auto timer_entry = retry_timer_pool_.front(); + if (timer_entry.first->is_running()) { + return timer_entry.second; + } + retry_timer_pool_.pop(); + } + return std::string(); +} + ConnectionStatus TransportAdapterImpl::GetConnectionStatus( const DeviceUID& device_handle) const { DeviceSptr device = FindDevice(device_handle); |