From 5b2422768e8290b248206124343887e1ed2c1680 Mon Sep 17 00:00:00 2001 From: zuojiangjiang Date: Sat, 12 Mar 2022 16:09:21 +0800 Subject: [PATCH] fix the distributeddata service start Signed-off-by: zuojiangjiang --- .../app/src/kvstore_data_service.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index 366e33884..40b0c5f8e 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -834,6 +834,14 @@ void KvStoreDataService::AddPermission() const void KvStoreDataService::OnStart() { ZLOGI("distributeddata service onStart"); + static constexpr int32_t RETRY_TIMES = 10; + static constexpr int32_t RETRY_INTERVAL = 500 * 1000; // unit is ms + for (BlockInteger retry(RETRY_INTERVAL); retry < RETRY_TIMES; ++retry) { + if (!DeviceKvStoreImpl::GetLocalDeviceId().empty()) { + break; + } + ZLOGE("GetLocalDeviceId failed, retry count:%{public}d", static_cast(retry)); + } Initialize(); Bootstrap::GetInstance().LoadComponents(); Bootstrap::GetInstance().LoadDirectory(); @@ -855,15 +863,6 @@ void KvStoreDataService::OnStart() void KvStoreDataService::StartService() { - static constexpr int32_t RETRY_TIMES = 10; - static constexpr int32_t RETRY_INTERVAL = 500 * 1000; // unit is ms - for (BlockInteger retry(RETRY_INTERVAL); retry < RETRY_TIMES; ++retry) { - if (!DeviceKvStoreImpl::GetLocalDeviceId().empty()) { - break; - } - ZLOGE("GetLocalDeviceId failed, retry count:%{public}d", static_cast(retry)); - } - // register this to ServiceManager. bool ret = SystemAbility::Publish(this); if (!ret) { -- Gitee