Loading system/gd/module.cc +2 −0 Original line number Diff line number Diff line Loading @@ -95,8 +95,10 @@ void ModuleRegistry::StopAll() { ASSERT(instance != started_modules_.end()); // Clear the handler before stopping the module to allow it to shut down gracefully. LOG_INFO("Stopping Handler of Module %s", instance->second->ToString().c_str()); instance->second->handler_->Clear(); instance->second->handler_->WaitUntilStopped(kModuleStopTimeout); LOG_INFO("Stopping Module %s", instance->second->ToString().c_str()); instance->second->Stop(); } for (auto it = start_order_.rbegin(); it != start_order_.rend(); it++) { Loading system/gd/module_unittest.cc +5 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,9 @@ #include "gtest/gtest.h" #include <functional> #include <future> using ::bluetooth::os::Thread; namespace bluetooth { Loading Loading @@ -207,7 +210,7 @@ TEST_F(ModuleTest, two_dependencies) { EXPECT_FALSE(registry_->IsStarted<TestModuleTwoDependencies>()); } void post_two_module_one_handler() { void post_to_module_one_handler() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); test_module_one_dependency_handler->Post(common::BindOnce([] { FAIL(); })); } Loading @@ -216,7 +219,7 @@ TEST_F(ModuleTest, shutdown_with_unhandled_callback) { ModuleList list; list.add<TestModuleOneDependency>(); registry_->Start(&list, thread_); test_module_no_dependency_handler->Post(common::BindOnce(&post_two_module_one_handler)); test_module_no_dependency_handler->Post(common::BindOnce(&post_to_module_one_handler)); registry_->StopAll(); } Loading system/gd/os/linux_generic/reactor.cc +3 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,9 @@ bool Reactor::WaitForUnregisteredReactable(std::chrono::milliseconds timeout) { return true; } auto stop_status = executing_reactable_finished_->wait_for(timeout); if (stop_status != std::future_status::ready) { LOG_ERROR("Unregister reactable timed out"); } return stop_status == std::future_status::ready; } Loading system/gd/stack_manager.cc +2 −2 Original line number Diff line number Diff line Loading @@ -57,11 +57,11 @@ void StackManager::ShutDown() { auto future = promise.get_future(); handler_->Post(common::BindOnce(&StackManager::handle_shut_down, common::Unretained(this), std::move(promise))); auto stop_status = future.wait_for(std::chrono::seconds(3)); auto stop_status = future.wait_for(std::chrono::seconds(5)); ASSERT_LOG(stop_status == std::future_status::ready, "Can't stop stack"); handler_->Clear(); handler_->WaitUntilStopped(std::chrono::milliseconds(20)); handler_->WaitUntilStopped(std::chrono::milliseconds(2000)); delete handler_; delete management_thread_; } Loading Loading
system/gd/module.cc +2 −0 Original line number Diff line number Diff line Loading @@ -95,8 +95,10 @@ void ModuleRegistry::StopAll() { ASSERT(instance != started_modules_.end()); // Clear the handler before stopping the module to allow it to shut down gracefully. LOG_INFO("Stopping Handler of Module %s", instance->second->ToString().c_str()); instance->second->handler_->Clear(); instance->second->handler_->WaitUntilStopped(kModuleStopTimeout); LOG_INFO("Stopping Module %s", instance->second->ToString().c_str()); instance->second->Stop(); } for (auto it = start_order_.rbegin(); it != start_order_.rend(); it++) { Loading
system/gd/module_unittest.cc +5 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,9 @@ #include "gtest/gtest.h" #include <functional> #include <future> using ::bluetooth::os::Thread; namespace bluetooth { Loading Loading @@ -207,7 +210,7 @@ TEST_F(ModuleTest, two_dependencies) { EXPECT_FALSE(registry_->IsStarted<TestModuleTwoDependencies>()); } void post_two_module_one_handler() { void post_to_module_one_handler() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); test_module_one_dependency_handler->Post(common::BindOnce([] { FAIL(); })); } Loading @@ -216,7 +219,7 @@ TEST_F(ModuleTest, shutdown_with_unhandled_callback) { ModuleList list; list.add<TestModuleOneDependency>(); registry_->Start(&list, thread_); test_module_no_dependency_handler->Post(common::BindOnce(&post_two_module_one_handler)); test_module_no_dependency_handler->Post(common::BindOnce(&post_to_module_one_handler)); registry_->StopAll(); } Loading
system/gd/os/linux_generic/reactor.cc +3 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,9 @@ bool Reactor::WaitForUnregisteredReactable(std::chrono::milliseconds timeout) { return true; } auto stop_status = executing_reactable_finished_->wait_for(timeout); if (stop_status != std::future_status::ready) { LOG_ERROR("Unregister reactable timed out"); } return stop_status == std::future_status::ready; } Loading
system/gd/stack_manager.cc +2 −2 Original line number Diff line number Diff line Loading @@ -57,11 +57,11 @@ void StackManager::ShutDown() { auto future = promise.get_future(); handler_->Post(common::BindOnce(&StackManager::handle_shut_down, common::Unretained(this), std::move(promise))); auto stop_status = future.wait_for(std::chrono::seconds(3)); auto stop_status = future.wait_for(std::chrono::seconds(5)); ASSERT_LOG(stop_status == std::future_status::ready, "Can't stop stack"); handler_->Clear(); handler_->WaitUntilStopped(std::chrono::milliseconds(20)); handler_->WaitUntilStopped(std::chrono::milliseconds(2000)); delete handler_; delete management_thread_; } Loading