OSDN Git Service

GD Storage: Call SaveDelayed on the right thread
authorJack He <siyuanh@google.com>
Sat, 17 Apr 2021 08:37:25 +0000 (01:37 -0700)
committerJack He <siyuanh@google.com>
Sat, 17 Apr 2021 08:42:26 +0000 (08:42 +0000)
* To resolve a dedlock between StorageModule and ConfigCache

Fixes: 178976563
Bug: 178976563
Test: atest bluetooth_test_gd
Tag: #gd-refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I13a51931111eb3c0e1c999cd4b7f4fc30d9e1f13

gd/storage/storage_module.cc

index b862251..6b4e9bc 100644 (file)
@@ -175,7 +175,7 @@ void StorageModule::Start() {
     config->SetProperty(kInfoSection, kTimeCreatedProperty, ss.str());
   }
   config->FixDeviceTypeInconsistencies();
-  config->SetPersistentConfigChangedCallback([this] { this->SaveDelayed(); });
+  config->SetPersistentConfigChangedCallback([this] { this->CallOn(this, &StorageModule::SaveDelayed); });
   // TODO (b/158035889) Migrate metrics module to GD
   pimpl_ = std::make_unique<impl>(GetHandler(), std::move(config.value()), temp_devices_capacity_);
   SaveDelayed();