summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhdanovP <pzhdanov@luxoft.com>2018-08-23 14:57:10 +0300
committerZhdanovP <pzhdanov@luxoft.com>2018-10-17 15:53:35 +0300
commit92e8ec3038017c0b83ed838a78436b98f3bda7e2 (patch)
tree260f2a0fa9c5b3579dfed26d9a13cda33dd34a1d
parent73e4f50de1b77e1c938f31226f180f3c63a566fc (diff)
downloadsdl_core-fix/Move_app_launcher_stop_before_unregister_app.tar.gz
Move app launcher stop before unregister appfix/Move_app_launcher_stop_before_unregister_app
The applauncher has to be stopped before appropriate application will be unregistered. Otherwise it could lead to core crash, when Launch controller will try to run already non existed application
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h26
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h2
-rw-r--r--src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h4
-rw-r--r--src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc7
-rw-r--r--src/components/application_manager/src/app_launch/device_apps_launcher.cc23
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc7
6 files changed, 59 insertions, 10 deletions
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
index a10963ad82..35fda76874 100644
--- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl.h
@@ -49,23 +49,29 @@ namespace app_launch {
class AppLaunchCtrl {
public:
/**
- * @brief OnAppRegistered should be called when application registered
- * Save application parameters to database
- * @param app application to save
- */
+ * @brief OnAppRegistered should be called when application registered
+ * Save application parameters to database
+ * @param app application to save
+ */
virtual void OnAppRegistered(const application_manager::Application& app) = 0;
/**
- * @brief OnDeviceConnected shoudl be called on device connected event
- * Start launching saaved applications on ios device
- * @param device_mac
- */
+ * @brief OnDeviceConnected should be called on device connected event
+ * Start launching saved applications on ios device
+ * @param device_mac
+ */
virtual void OnDeviceConnected(const std::string& device_mac) = 0;
/**
- * @brief OnMasterReset clear database of saved applications
- */
+ * @brief OnMasterReset clear database of saved applications
+ */
virtual void OnMasterReset() = 0;
+
+ /**
+ * @brief Stop - allows to stop app launcher.
+ */
+ virtual void Stop() = 0;
+
virtual ~AppLaunchCtrl() {}
};
diff --git a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
index 61f3480f77..6436ba18cd 100644
--- a/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
+++ b/src/components/application_manager/include/application_manager/app_launch/app_launch_ctrl_impl.h
@@ -69,6 +69,7 @@ class AppLaunchCtrlImpl : public AppLaunchCtrl {
void OnAppRegistered(const application_manager::Application& app) OVERRIDE;
void OnDeviceConnected(const std::string& device_mac) OVERRIDE;
void OnMasterReset() OVERRIDE;
+ void Stop() OVERRIDE;
private:
const AppLaunchSettings& settings_;
@@ -77,6 +78,7 @@ class AppLaunchCtrlImpl : public AppLaunchCtrl {
AppsLauncher apps_launcher_;
DeviceAppsLauncher device_apps_launcher_;
+ sync_primitives::Lock launch_ctrl_lock_;
DISALLOW_COPY_AND_ASSIGN(AppLaunchCtrlImpl);
};
diff --git a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
index f156654215..0f70c32aa7 100644
--- a/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
+++ b/src/components/application_manager/include/application_manager/app_launch/device_apps_launcher.h
@@ -35,8 +35,11 @@ class DeviceAppsLauncherImpl {
};
bool StopLaunchingAppsOnDevice(const std::string& device_mac);
+ void StopLaunchingAppsOnAllDevices();
private:
+ void StopLauncher(std::shared_ptr<Launcher> launcher);
+
sync_primitives::Lock launchers_lock_;
std::vector<std::shared_ptr<Launcher> > free_launchers_;
std::vector<std::shared_ptr<Launcher> > works_launchers_;
@@ -60,6 +63,7 @@ class DeviceAppsLauncher {
const std::string& device_mac,
const std::vector<ApplicationDataPtr>& applications_to_launch);
bool StopLaunchingAppsOnDevice(const std::string& device_mac);
+ void StopLaunchingAppsOnAllDevices();
const AppLaunchSettings& settings() const;
diff --git a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
index 8df3d436bd..0fa2305685 100644
--- a/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
+++ b/src/components/application_manager/src/app_launch/app_launch_ctrl_impl.cc
@@ -83,6 +83,7 @@ bool HmiLevelSorter(const std::pair<int32_t, ApplicationDataPtr>& lval,
void AppLaunchCtrlImpl::OnDeviceConnected(const std::string& device_mac) {
LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launch_ctrl_lock_);
std::vector<ApplicationDataPtr> apps_on_device =
app_launch_data_.GetApplicationDataByDevice(device_mac);
std::vector<std::pair<int32_t, ApplicationDataPtr> > apps_hmi_levels;
@@ -112,4 +113,10 @@ void AppLaunchCtrlImpl::OnMasterReset() {
LOG4CXX_AUTO_TRACE(logger_);
app_launch_data_.Clear();
}
+
+void AppLaunchCtrlImpl::Stop() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launch_ctrl_lock_);
+ device_apps_launcher_.StopLaunchingAppsOnAllDevices();
+}
} // namespace app_launch
diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
index a4468d87bc..b9f33b5551 100644
--- a/src/components/application_manager/src/app_launch/device_apps_launcher.cc
+++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc
@@ -10,6 +10,7 @@
#include "utils/timer.h"
#include "utils/timer_task_impl.h"
#include <iostream>
+#include <boost/bind.hpp>
namespace app_launch {
CREATE_LOGGERPTR_GLOBAL(logger_, "AppLaunch")
@@ -168,6 +169,24 @@ bool DeviceAppsLauncherImpl::StopLaunchingAppsOnDevice(
return true;
}
+void DeviceAppsLauncherImpl::StopLauncher(LauncherPtr launcher) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ launcher->Clear();
+ free_launchers_.push_back(launcher);
+}
+
+void DeviceAppsLauncherImpl::StopLaunchingAppsOnAllDevices() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(launchers_lock_);
+
+ std::for_each(
+ works_launchers_.begin(),
+ works_launchers_.end(),
+ boost::bind(&DeviceAppsLauncherImpl::StopLauncher, this, _1));
+
+ works_launchers_.clear();
+}
+
bool DeviceAppsLauncher::LaunchAppsOnDevice(
const std::string& device_mac,
const std::vector<ApplicationDataPtr>& applications_to_launch) {
@@ -187,6 +206,10 @@ bool DeviceAppsLauncher::StopLaunchingAppsOnDevice(
return impl_->StopLaunchingAppsOnDevice(device_mac);
}
+void DeviceAppsLauncher::StopLaunchingAppsOnAllDevices() {
+ impl_->StopLaunchingAppsOnAllDevices();
+}
+
const AppLaunchSettings& DeviceAppsLauncher::settings() const {
return settings_;
}
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index f6960e5583..68771a1f2f 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -1755,6 +1755,11 @@ bool ApplicationManagerImpl::Stop() {
stopping_application_mng_lock_.Acquire();
is_stopping_ = true;
stopping_application_mng_lock_.Release();
+
+ if (app_launch_ctrl_) {
+ app_launch_ctrl_->Stop();
+ }
+
application_list_update_timer_.Stop();
try {
SetUnregisterAllApplicationsReason(
@@ -1766,6 +1771,8 @@ bool ApplicationManagerImpl::Stop() {
}
request_ctrl_.DestroyThreadpool();
+ hmi_handler_ = nullptr;
+
// for PASA customer policy backup should happen :AllApp(SUSPEND)
LOG4CXX_DEBUG(logger_, "Unloading policy library.");
GetPolicyHandler().UnloadPolicyLibrary();