diff options
author | Asen Kirov <akirov@luxoft.com> | 2015-10-22 15:42:18 +0300 |
---|---|---|
committer | Asen Kirov <akirov@luxoft.com> | 2015-10-22 15:42:18 +0300 |
commit | 2b76d0ccac3ceb0e6568fef95bd874b7d7a598d7 (patch) | |
tree | dd72d81bdf424096a696437385298f4dae36f04c /src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h | |
parent | cee517d5ff7f7aeecef453460ebeef79bdcef4e1 (diff) | |
download | sdl_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.h | 1 |
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, |