summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
diff options
context:
space:
mode:
authorAsen Kirov <akirov@luxoft.com>2015-10-22 15:42:18 +0300
committerAsen Kirov <akirov@luxoft.com>2015-10-22 15:42:18 +0300
commit2b76d0ccac3ceb0e6568fef95bd874b7d7a598d7 (patch)
treedd72d81bdf424096a696437385298f4dae36f04c /src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
parentcee517d5ff7f7aeecef453460ebeef79bdcef4e1 (diff)
downloadsdl_core-2b76d0ccac3ceb0e6568fef95bd874b7d7a598d7.tar.gz
Fix race condition in Singleton and Application Manager failure to stop
When SDL is started, but the HMI is not, and we try to register a mobile app (RegisterAppInterfaceRequest), then in this situation SDL can't be stopped with ctrl+C - it enters in an endless cycle. The reason for the problem is that we can't delete the AM, because the RequestController thread of AM is still running (waiting in a cycle for the HMI to respond). Also a second AM is created, because in the Singleton we set to 0 the instance pointer before deleting it and someone calls instance() before destroy() finishes, because there is no common lock. The separate locks create a race condition. The fix is to use a single mutex for the Singleton methods, introduce a is_stopping_ flag in AM, set it to true in AM's Stop() method, and also destroy RequestController's thread pool there. Then check stop flag in RegisterAppInterfaceRequest::Run() and exit the HMI waiting cycle there.
Diffstat (limited to 'src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h')
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
index cad956ead5..bc6a4e6ba4 100644
--- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h
@@ -313,6 +313,7 @@ class ApplicationManagerImpl : public ApplicationManager,
MOCK_METHOD3(set_state, void(ApplicationSharedPtr app,
mobile_apis::HMILevel::eType,
mobile_apis::AudioStreamingState::eType));
+MOCK_CONST_METHOD0(IsStopping, bool());
struct ApplicationsAppIdSorter {
bool operator() (const ApplicationSharedPtr lhs,