From 39843a3b8336199c4397137109418d828f6397c1 Mon Sep 17 00:00:00 2001 From: s30051537 Date: Wed, 3 Jan 2024 16:21:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A1=86=E6=9E=B6=E7=9C=8B?= =?UTF-8?q?=E6=9D=BF=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: s30051537 --- .../include/resourcemanager/db_adapter.h | 1 + .../src/resourcemanager/db_adapter.cpp | 23 +++++++++++-------- utils/src/dh_utils_tool.cpp | 5 +++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h b/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h index f2d052d1..64a9260b 100644 --- a/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h +++ b/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h @@ -73,6 +73,7 @@ private: void UnRegisterKvStoreDeathListener(); void RegisterManualSyncListener(); void UnRegisterManualSyncListener(); + void HandleManualSync(const std::string &deviceId); DistributedKv::Status GetKvStorePtr(); private: diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp index bc69c925..f0c1ea5b 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp @@ -142,19 +142,24 @@ void DBAdapter::SyncCompleted(const std::map manualSyncCountMap_[deviceId] = 0; } else { manualSyncCountMap_[deviceId]++; - if (manualSyncCountMap_[deviceId] >= MANUAL_SYNC_TIMES) { - manualSyncCountMap_[deviceId] = 0; - } else { - auto retryTask = [this, deviceId] { - this->ManualSync(deviceId); - usleep(MANUAL_SYNC_INTERVAL); - }; - DHContext::GetInstance().GetEventBus()->PostTask(retryTask, "retryTask", 0); - } + HandleManualSync(deviceId); } } } +void DBAdapter::HandleManualSync(const std::string &deviceId) +{ + if (manualSyncCountMap_[deviceId] >= MANUAL_SYNC_TIMES) { + manualSyncCountMap_[deviceId] = 0; + } else { + auto retryTask = [this, deviceId] { + this->ManualSync(deviceId); + usleep(MANUAL_SYNC_INTERVAL); + }; + DHContext::GetInstance().GetEventBus()->PostTask(retryTask, "retryTask", 0); + } +} + int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data) { DHLOGI("Get data by key: %s", GetAnonyString(key).c_str()); diff --git a/utils/src/dh_utils_tool.cpp b/utils/src/dh_utils_tool.cpp index 19d3b580..136675f8 100644 --- a/utils/src/dh_utils_tool.cpp +++ b/utils/src/dh_utils_tool.cpp @@ -50,7 +50,10 @@ std::string GetRandomID() static std::uniform_int_distribution dist(0ULL, 0xFFFFFFFFFFFFFFFFULL); uint64_t ab = dist(rd); uint64_t cd = dist(rd); - uint32_t a, b, c, d; + uint32_t a; + uint32_t b; + uint32_t c; + uint32_t d; std::stringstream ss; ab = (ab & 0xFFFFFFFFFFFF0FFFULL) | 0x0000000000004000ULL; cd = (cd & 0x3FFFFFFFFFFFFFFFULL) | 0x8000000000000000ULL; -- Gitee