diff --git a/frameworks/libs/distributeddb/common/include/auto_launch.h b/frameworks/libs/distributeddb/common/include/auto_launch.h index a2794eb96202242ae83091bc64591e417b3e0b3c..00075878d7ee04d78c4dad1750e358b6e6ccb0d7 100644 --- a/frameworks/libs/distributeddb/common/include/auto_launch.h +++ b/frameworks/libs/distributeddb/common/include/auto_launch.h @@ -40,7 +40,7 @@ enum class AutoLaunchItemState { }; enum class DBType { - DB_KV = 0, + DB_KV = 1, DB_RELATION, DB_INVALID, }; @@ -164,7 +164,7 @@ protected: void TryCloseRelationConnection(AutoLaunchItem &autoLaunchItem); - void EraseAutoLauchItem(const std::string &identifier, const std::string &userId); + void EraseAutoLaunchItem(const std::string &identifier, const std::string &userId); void NotifyInvalidParam(const AutoLaunchItem &autoLaunchItem); diff --git a/frameworks/libs/distributeddb/common/include/db_constant.h b/frameworks/libs/distributeddb/common/include/db_constant.h index 5db4590e9056caa53b1f58fc964eb113b5714e55..532cfae9d07418584a895d266c7111db5d1d293f 100644 --- a/frameworks/libs/distributeddb/common/include/db_constant.h +++ b/frameworks/libs/distributeddb/common/include/db_constant.h @@ -155,6 +155,8 @@ public: static constexpr uint32_t MAX_CONDITION_KEY_LEN = 128; static constexpr uint32_t MAX_CONDITION_VALUE_LEN = 128; static constexpr uint32_t MAX_CONDITION_COUNT = 32; + + static constexpr uint32_t REMOTE_QUERY_MAX_SQL_LEN = 1000000U; }; } // namespace DistributedDB diff --git a/frameworks/libs/distributeddb/common/include/db_dfx_adapter.h b/frameworks/libs/distributeddb/common/include/db_dfx_adapter.h index cc4f40cd06587eca4b6c7a86fc6acf548c28643a..b1b67e048c2f494b39a605c6326c3b9c5d88c514 100644 --- a/frameworks/libs/distributeddb/common/include/db_dfx_adapter.h +++ b/frameworks/libs/distributeddb/common/include/db_dfx_adapter.h @@ -33,7 +33,7 @@ struct ReportTask { std::string storeId; int errCode = 0; }; -class DBDfxAdapter { +class DBDfxAdapter final { public: static void Dump(int fd, const std::vector &args); diff --git a/frameworks/libs/distributeddb/common/include/db_types.h b/frameworks/libs/distributeddb/common/include/db_types.h index 656beaacae8717a1d56d17299a70c706b939ea6b..0ea4d305f46160f8e8c7b21f0adb60e81a463a7a 100644 --- a/frameworks/libs/distributeddb/common/include/db_types.h +++ b/frameworks/libs/distributeddb/common/include/db_types.h @@ -138,7 +138,7 @@ struct SyncTimeRange { }; // field types stored in sqlite -enum class StorageType { +enum class StorageType : int32_t { STORAGE_TYPE_NONE = 0, STORAGE_TYPE_NULL, STORAGE_TYPE_INTEGER, diff --git a/frameworks/libs/distributeddb/common/include/performance_analysis.h b/frameworks/libs/distributeddb/common/include/performance_analysis.h index 51a84dfe9215d5c2761f90a6324a985634d704cc..286fe4ac35a53a7e6f718e26b437f97c140767db 100644 --- a/frameworks/libs/distributeddb/common/include/performance_analysis.h +++ b/frameworks/libs/distributeddb/common/include/performance_analysis.h @@ -69,9 +69,6 @@ struct SingleStatistics { class PerformanceAnalysis { public: - explicit PerformanceAnalysis(uint32_t step); - ~PerformanceAnalysis(); - static PerformanceAnalysis *GetInstance(int stepNum = 20); void Initialization(); @@ -93,6 +90,9 @@ public: void SetFileName(const std::string &fileName); private: + explicit PerformanceAnalysis(uint32_t step); + + ~PerformanceAnalysis(); bool IsStepValid(uint32_t step) const; diff --git a/frameworks/libs/distributeddb/common/include/runtime_context.h b/frameworks/libs/distributeddb/common/include/runtime_context.h index e504950ba36f849929cd2808a7ba746be1d455b4..85c22557ed5b0b51ffe6569b6cad0dd04bfe0f6d 100644 --- a/frameworks/libs/distributeddb/common/include/runtime_context.h +++ b/frameworks/libs/distributeddb/common/include/runtime_context.h @@ -137,6 +137,8 @@ public: virtual int SetPermissionConditionCallback(const PermissionConditionCallback &callback) = 0; virtual std::map GetPermissionCheckParam(const DBProperties &properties) = 0; + + virtual void StopTaskPool() = 0; protected: RuntimeContext() = default; virtual ~RuntimeContext() {} diff --git a/frameworks/libs/distributeddb/common/include/semaphore_utils.h b/frameworks/libs/distributeddb/common/include/semaphore_utils.h index 9cdb3f561dc4bec5784670af7ab9c798b0dc957d..c5e96e24a228745abb7ed2e83e4295f1ae6b1150 100644 --- a/frameworks/libs/distributeddb/common/include/semaphore_utils.h +++ b/frameworks/libs/distributeddb/common/include/semaphore_utils.h @@ -16,8 +16,6 @@ #ifndef SEMAPHORE_UTILS_H #define SEMAPHORE_UTILS_H -#include -#include #include #include #include "macro_utils.h" diff --git a/frameworks/libs/distributeddb/common/src/auto_launch.cpp b/frameworks/libs/distributeddb/common/src/auto_launch.cpp index 5e599fde4c121e94e676b251cc519acccecdb6c6..db7db1f17cd9c8b9d5a85e18adfdacbda068d709 100644 --- a/frameworks/libs/distributeddb/common/src/auto_launch.cpp +++ b/frameworks/libs/distributeddb/common/src/auto_launch.cpp @@ -62,13 +62,13 @@ void AutoLaunch::SetCommunicatorAggregator(ICommunicatorAggregator *aggregator) errCode = aggregator->RegOnConnectCallback(std::bind(&AutoLaunch::OnlineCallBack, this, std::placeholders::_1, std::placeholders::_2), nullptr); if (errCode != E_OK) { - LOGW("[AutoLaunch] RegOnConnectCallback errCode:%d", errCode); + LOGE("[AutoLaunch] RegOnConnectCallback errCode:%d", errCode); } errCode = aggregator->RegCommunicatorLackCallback( std::bind(&AutoLaunch::ReceiveUnknownIdentifierCallBack, this, std::placeholders::_1, std::placeholders::_2), nullptr); if (errCode != E_OK) { - LOGW("[AutoLaunch] RegCommunicatorLackCallback errCode:%d", errCode); + LOGE("[AutoLaunch] RegCommunicatorLackCallback errCode:%d", errCode); } } @@ -205,7 +205,7 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st return E_OK; } if (autoLaunchItem.conn == nullptr) { - EraseAutoLauchItem(identifier, userId); + EraseAutoLaunchItem(identifier, userId); return errCode; } bool isEmpty = false; @@ -219,7 +219,7 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st errCode = KvDBManager::ReleaseDatabaseConnection(kvConn); if (errCode != E_OK) { LOGE("[AutoLaunch] GetKVConnectionInEnable ReleaseDatabaseConnection failed errCode:%d", errCode); - EraseAutoLauchItem(identifier, userId); + EraseAutoLaunchItem(identifier, userId); return errCode; } std::lock_guard autoLock(dataLock_); @@ -235,7 +235,7 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st } else { LOGE("[AutoLaunch] GetKVConnectionInEnable RegisterObserverAndLifeCycleCallback err, do CloseConnection"); TryCloseConnection(autoLaunchItem); // do nothing if failed - EraseAutoLauchItem(identifier, userId); + EraseAutoLaunchItem(identifier, userId); } return errCode; } @@ -384,11 +384,12 @@ void AutoLaunch::ObserverFunc(const KvDBCommitNotifyData ¬ifyData, const std: int AutoLaunch::DisableKvStoreAutoLaunch(const std::string &normalIdentifier, const std::string &dualTupleIdentifier, const std::string &userId) { - std::string identifier = (autoLaunchItemMap_.count(normalIdentifier) == 0) ? dualTupleIdentifier : normalIdentifier; - LOGI("[AutoLaunch] DisableKvStoreAutoLaunch identifier=%.6s", STR_TO_HEX(identifier)); + std::string identifier; AutoLaunchItem autoLaunchItem; { std::unique_lock autoLock(dataLock_); + identifier = (autoLaunchItemMap_.count(normalIdentifier) == 0) ? dualTupleIdentifier : normalIdentifier; + LOGI("[AutoLaunch] DisableKvStoreAutoLaunch identifier=%.6s", STR_TO_HEX(identifier)); if (autoLaunchItemMap_.count(identifier) == 0 || autoLaunchItemMap_[identifier].count(userId) == 0) { LOGE("[AutoLaunch] DisableKvStoreAutoLaunch identifier is not exist!"); return -E_NOT_FOUND; @@ -423,7 +424,7 @@ int AutoLaunch::DisableKvStoreAutoLaunch(const std::string &normalIdentifier, co return errCode; } - EraseAutoLauchItem(identifier, userId); + EraseAutoLaunchItem(identifier, userId); cv_.notify_all(); if (autoLaunchItem.isWriteOpenNotified && autoLaunchItem.notifier) { RuntimeContext::GetInstance()->ScheduleTask([autoLaunchItem] { CloseNotifier(autoLaunchItem); }); @@ -693,17 +694,20 @@ int AutoLaunch::ReceiveUnknownIdentifierCallBack(const LabelType &label, const s const std::string identifier(label.begin(), label.end()); // originalUserId size maybe 0 std::string userId = originalUserId; - if (originalUserId.size() == 0 && autoLaunchItemMap_.count(identifier) != 0 && - autoLaunchItemMap_[identifier].size() > 1) { - LOGE("[AutoLaunch] normal tuple mode userId larger than one userId"); - goto EXT; - } - if (originalUserId.size() == 0 && autoLaunchItemMap_.count(identifier) != 0 && - autoLaunchItemMap_[identifier].size() == 1) { - // normal tuple mode - userId = autoLaunchItemMap_[identifier].begin()->first; + { + std::lock_guard autoLock(dataLock_); + if (originalUserId.size() == 0 && autoLaunchItemMap_.count(identifier) != 0 && + autoLaunchItemMap_[identifier].size() > 1) { + LOGE("[AutoLaunch] normal tuple mode userId larger than one userId"); + goto EXT; + } + if (originalUserId.size() == 0 && autoLaunchItemMap_.count(identifier) != 0 && + autoLaunchItemMap_[identifier].size() == 1) { + // normal tuple mode + userId = autoLaunchItemMap_[identifier].begin()->first; + } + LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack identifier=%.6s", STR_TO_HEX(identifier)); } - LOGI("[AutoLaunch] ReceiveUnknownIdentifierCallBack identifier=%.6s", STR_TO_HEX(identifier)); int errCode; { std::lock_guard autoLock(dataLock_); @@ -733,7 +737,6 @@ int AutoLaunch::ReceiveUnknownIdentifierCallBack(const LabelType &label, const s autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IDLE; } return errCode; - EXT: return AutoLaunchExt(identifier, userId); } @@ -1179,7 +1182,7 @@ void AutoLaunch::TryCloseRelationConnection(AutoLaunchItem &autoLaunchItem) } } -void AutoLaunch::EraseAutoLauchItem(const std::string &identifier, const std::string &userId) +void AutoLaunch::EraseAutoLaunchItem(const std::string &identifier, const std::string &userId) { std::lock_guard autoLock(dataLock_); autoLaunchItemMap_[identifier].erase(userId); diff --git a/frameworks/libs/distributeddb/common/src/data_value.cpp b/frameworks/libs/distributeddb/common/src/data_value.cpp index d5f7ae772e7813598fc009213252cf111852aebd..99fc897dcbb66b061a7e7a2a8aa2fbf05c10fc65 100644 --- a/frameworks/libs/distributeddb/common/src/data_value.cpp +++ b/frameworks/libs/distributeddb/common/src/data_value.cpp @@ -84,9 +84,7 @@ int Blob::WriteBlob(const uint8_t *ptrArray, const uint32_t &size) std::vector Blob::ToVector() const { - std::vector vec; - vec.insert(vec.end(), ptr_, ptr_ + size_); - return vec; + return std::vector(ptr_, ptr_ + size_); } DataValue::DataValue() : type_(StorageType::STORAGE_TYPE_NULL) diff --git a/frameworks/libs/distributeddb/common/src/evloop/include/event_fd.h b/frameworks/libs/distributeddb/common/src/evloop/src/event_fd.h similarity index 100% rename from frameworks/libs/distributeddb/common/src/evloop/include/event_fd.h rename to frameworks/libs/distributeddb/common/src/evloop/src/event_fd.h diff --git a/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.h b/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.h index 48964b5585161d970ec98bacbbd29ce326d2fe11..da3eb074927a102f3427c524a5d1fbf1c43a0fc6 100644 --- a/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.h +++ b/frameworks/libs/distributeddb/common/src/evloop/src/event_impl.h @@ -18,7 +18,7 @@ #include #include -#include "../include/ievent.h" +#include "ievent.h" namespace DistributedDB { class EventLoopImpl; diff --git a/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp b/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp index bc920a86464796defbdc12b7a31d327ccca6f4a7..61d539c7d691a8726947676ca4c57d7fc1260c22 100644 --- a/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp +++ b/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.cpp @@ -98,7 +98,8 @@ private: }; EventLoopImpl::EventLoopImpl() - : pollingSetChanged_(false) + : pollingSetChanged_(false), + running_(true) { OnKill([this](){ OnKillLoop(); }); } @@ -169,7 +170,7 @@ int EventLoopImpl::Run() int errCode; IncObjRef(this); - while (true) { + while (running_) { errCode = ProcessRequest(); if (errCode != E_OK) { break; @@ -207,6 +208,12 @@ int EventLoopImpl::Run() return errCode; } +int EventLoopImpl::Stop() +{ + running_ = false; + return E_OK; +} + int EventLoopImpl::Modify(EventImpl *event, bool isAdd, EventsMask events) { if (event == nullptr) { diff --git a/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.h b/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.h index 91c270ba396cabd2a73a0638536d77d317f95bba..2fc2c502677e87c3ffbe8c652c4ffe55a4820a45 100644 --- a/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.h +++ b/frameworks/libs/distributeddb/common/src/evloop/src/event_loop_impl.h @@ -20,8 +20,8 @@ #include #include #include "platform_specific.h" -#include "../include/ievent_loop.h" -#include "../include/ievent.h" +#include "ievent_loop.h" +#include "ievent.h" #if defined EVLOOP_TIMER_ONLY #define EVENT_LOOP_USE_SELECT @@ -42,6 +42,7 @@ public: int Add(IEvent *event) override; int Remove(IEvent *event) override; int Run() override; + int Stop() override; int Modify(EventImpl *event, bool isAdd, EventsMask events); int Modify(EventImpl *event, EventTime time); @@ -79,6 +80,7 @@ private: std::set polling_; bool pollingSetChanged_; std::thread::id loopThread_; + volatile bool running_; }; } diff --git a/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp b/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp index 361edfe06a508b0f66c45ec6e0d9d2f06b72e2a9..de28f3261902fdde49c55d6e97a0571889c63790 100644 --- a/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp +++ b/frameworks/libs/distributeddb/common/src/evloop/src/ievent.cpp @@ -13,7 +13,8 @@ * limitations under the License. */ -#include "../include/ievent.h" +#include "ievent.h" + #include "db_errno.h" #include "event_impl.h" diff --git a/frameworks/libs/distributeddb/common/src/evloop/include/ievent.h b/frameworks/libs/distributeddb/common/src/evloop/src/ievent.h similarity index 100% rename from frameworks/libs/distributeddb/common/src/evloop/include/ievent.h rename to frameworks/libs/distributeddb/common/src/evloop/src/ievent.h diff --git a/frameworks/libs/distributeddb/common/src/evloop/include/ievent_loop.h b/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.h similarity index 97% rename from frameworks/libs/distributeddb/common/src/evloop/include/ievent_loop.h rename to frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.h index b7451b8c4129afd4676709c8cbd89416a881d2f4..cfb3805317635c5630cf825592d753a389e1c9d8 100644 --- a/frameworks/libs/distributeddb/common/src/evloop/include/ievent_loop.h +++ b/frameworks/libs/distributeddb/common/src/evloop/src/ievent_loop.h @@ -38,6 +38,8 @@ public: // Run the loop. virtual int Run() = 0; + virtual int Stop() = 0; + // Create a loop object. static IEventLoop *CreateEventLoop(int &errCode); diff --git a/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp b/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp index 8e50136ced0828149a7f6acb46c9d649556404ff..4c19a06ab51ec8895d84b1f19fd151236891223c 100644 --- a/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp +++ b/frameworks/libs/distributeddb/common/src/flatbuffer_schema.cpp @@ -241,9 +241,14 @@ int SchemaObject::FlatBufferSchema::VerifyFlatBufferValue(const RawValue &inValu } namespace { +struct BaseTypeNode { + reflection::BaseType type; + FieldType fieldType; +}; + FieldType MapFieldType(reflection::BaseType inType) { - static std::map fieldTypeMap{ + static const BaseTypeNode baseTypeNodes[] = { {reflection::BaseType::Bool, FieldType::LEAF_FIELD_BOOL}, {reflection::BaseType::Byte, FieldType::LEAF_FIELD_INTEGER}, {reflection::BaseType::UByte, FieldType::LEAF_FIELD_INTEGER}, @@ -257,12 +262,14 @@ FieldType MapFieldType(reflection::BaseType inType) {reflection::BaseType::Double, FieldType::LEAF_FIELD_DOUBLE}, {reflection::BaseType::String, FieldType::LEAF_FIELD_STRING}, {reflection::BaseType::Vector, FieldType::LEAF_FIELD_ARRAY}, - {reflection::BaseType::Obj, FieldType::INTERNAL_FIELD_OBJECT}, + {reflection::BaseType::Obj, FieldType::INTERNAL_FIELD_OBJECT} }; - if (fieldTypeMap.count(inType) == 0) { - return FieldType::LEAF_FIELD_NULL; + for (const auto &node : baseTypeNodes) { + if (node.type == inType) { + return node.fieldType; + } } - return fieldTypeMap[inType]; + return FieldType::LEAF_FIELD_NULL; } RawString CheckDollarDotAndSkipIt(RawString inPath) diff --git a/frameworks/libs/distributeddb/common/src/notification_chain.cpp b/frameworks/libs/distributeddb/common/src/notification_chain.cpp index 237fcf9d38a952a276f5e06e741d1d6bb1d66ef7..02a83c3f6a6db27127f71475d42aaffdceff0f5a 100644 --- a/frameworks/libs/distributeddb/common/src/notification_chain.cpp +++ b/frameworks/libs/distributeddb/common/src/notification_chain.cpp @@ -186,7 +186,7 @@ int NotificationChain::ListenerChain::UnRegisterListener(Listener *listener, boo void NotificationChain::ListenerChain::BackupListenerSet(std::set &backupSet) const { for (auto listener : listenerSet_) { - listener->IncObjRef(listener); + RefObject::IncObjRef(listener); backupSet.insert(listener); } } diff --git a/frameworks/libs/distributeddb/common/src/parcel.cpp b/frameworks/libs/distributeddb/common/src/parcel.cpp index 815597416fac4d7b0f33071646184778e6420739..0041d37cf625260a5b3689286bf454a0fa0e3622 100644 --- a/frameworks/libs/distributeddb/common/src/parcel.cpp +++ b/frameworks/libs/distributeddb/common/src/parcel.cpp @@ -524,6 +524,15 @@ uint32_t Parcel::GetMultiVerCommitsLen(const std::vector &co void Parcel::EightByteAlign() { + if (IsError()) { + LOGE("EightByteAlign already error"); + return; + } + if (BYTE_8_ALIGN(parcelLen_) > totalLen_) { + LOGE("byte 8 align failed"); + isError_ = true; + return; + } bufPtr_ += BYTE_8_ALIGN(parcelLen_) - parcelLen_; parcelLen_ = BYTE_8_ALIGN(parcelLen_); } diff --git a/frameworks/libs/distributeddb/common/src/platform_specific.cpp b/frameworks/libs/distributeddb/common/src/platform_specific.cpp index 8e087dfa084fc00c691e304f9632096838b60d1d..839d643b5588d013a835de7c3b2352f03394c909 100644 --- a/frameworks/libs/distributeddb/common/src/platform_specific.cpp +++ b/frameworks/libs/distributeddb/common/src/platform_specific.cpp @@ -456,6 +456,7 @@ int GetRealPath(const std::string &inOriPath, std::string &outRealPath) return E_OK; } +#ifndef RUNNING_ON_SIMULATED_ENV int GetCurrentSysTimeInMicrosecond(uint64_t &outTime) { struct timeval rawTime; @@ -468,6 +469,7 @@ int GetCurrentSysTimeInMicrosecond(uint64_t &outTime) static_cast(rawTime.tv_usec); return E_OK; } +#endif // RUNNING_ON_SIMULATED_ENV namespace { const uint64_t MULTIPLES_BETWEEN_MICROSECONDS_AND_NANOSECONDS = 1000; diff --git a/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp b/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp index 03db2eb0f285673b6c975cbe3aa55f93404a3767..285596f4f09c085275feaf38b71b5ce9fa789232 100644 --- a/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp +++ b/frameworks/libs/distributeddb/common/src/relational/prepared_stmt.cpp @@ -89,7 +89,7 @@ int PreparedStmt::Serialize(Parcel &parcel) const } } - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); if (parcel.IsError()) { return -E_PARSE_FAIL; } @@ -137,7 +137,10 @@ int PreparedStmt::DeSerialize(Parcel &parcel) } } - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); + if (parcel.IsError()) { + return -E_PARSE_FAIL; + } return E_OK; } } diff --git a/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp b/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp index e602066006e94fc46ab81d3456c4bf6e042e9b2d..46a2bac72f2a2187d32028e4ade0fab424e0b85f 100644 --- a/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp +++ b/frameworks/libs/distributeddb/common/src/relational/relational_row_data_set.cpp @@ -79,7 +79,7 @@ int RelationalRowDataSet::Serialize(Parcel &parcel) const rowData->Serialize(parcel); }; - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); if (parcel.IsError()) { return -E_PARSE_FAIL; } @@ -118,7 +118,10 @@ int RelationalRowDataSet::DeSerialize(Parcel &parcel) } data_.push_back(rowData); } - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); + if (parcel.IsError()) { + return -E_PARSE_FAIL; + } return E_OK; }; diff --git a/frameworks/libs/distributeddb/common/src/relational/table_info.cpp b/frameworks/libs/distributeddb/common/src/relational/table_info.cpp index ca82ea7a6104c42c27bb04988e1055c553e41357..0ad6fd4a54510f96b8feb2f5a1f8b575ff96d47b 100644 --- a/frameworks/libs/distributeddb/common/src/relational/table_info.cpp +++ b/frameworks/libs/distributeddb/common/src/relational/table_info.cpp @@ -418,7 +418,6 @@ int TableInfo::CompareWithTableFields(const std::map &in auto itInTable = inTableFields.begin(); int errCode = -E_RELATIONAL_TABLE_EQUAL; while (itLocal != fields_.end() && itInTable != inTableFields.end()) { - LOGD("--> field name %s", itLocal->first.c_str()); if (itLocal->first == itInTable->first) { // Same field if (!itLocal->second.CompareWithField(itInTable->second, isLite)) { // Compare field LOGW("[Relational][Compare] Table field is incompatible"); // not compatible @@ -560,8 +559,6 @@ int TableInfo::CompareWithLiteTableFields(const std::map int TableInfo::CompareWithLiteSchemaTable(const TableInfo &liteTableInfo) const { - LOGE("--> check table primary key, %d %d %d", primaryKey_.empty(), liteTableInfo.GetPrimaryKey().empty(), autoInc_); - if (!liteTableInfo.GetPrimaryKey().empty() && (primaryKey_.at(0) != "rowid") && liteTableInfo.GetPrimaryKey() != primaryKey_) { LOGE("[Relational][Compare] Table primary key is not same"); diff --git a/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp b/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp index 0fba976541a6131bf950fa75df458c615ef5cf8d..8398c979b1f0b460c6b4364776d2c7b71687cc43 100644 --- a/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp +++ b/frameworks/libs/distributeddb/common/src/runtime_context_impl.cpp @@ -48,6 +48,7 @@ RuntimeContextImpl::~RuntimeContextImpl() taskPool_ = nullptr; } if (mainLoop_ != nullptr) { + mainLoop_->Stop(); mainLoop_->KillAndDecObjRef(mainLoop_); mainLoop_ = nullptr; } @@ -392,9 +393,8 @@ int RuntimeContextImpl::RunPermissionCheck(const PermissionCheckParam ¶m, ui } if (checkResult) { return E_OK; - } else { - return -E_NOT_PERMIT; } + return -E_NOT_PERMIT; } int RuntimeContextImpl::EnableKvStoreAutoLaunch(const KvDBProperties &properties, AutoLaunchNotifier notifier, @@ -542,6 +542,7 @@ bool RuntimeContextImpl::CheckDeviceSecurityAbility(const std::string &devId, co { std::lock_guard autoLock(systemApiAdapterLock_); if (systemApiAdapter_ == nullptr) { + LOGI("[CheckDeviceSecurityAbility] security not set"); return true; } tempSystemApiAdapter = systemApiAdapter_; @@ -722,4 +723,14 @@ std::map RuntimeContextImpl::GetPermissionCheckParam(c } return permissionConditionCallback_(param); } + +void RuntimeContextImpl::StopTaskPool() +{ + std::lock_guard autoLock(taskLock_); + if (taskPool_ != nullptr) { + taskPool_->Stop(); + TaskPool::Release(taskPool_); + taskPool_ = nullptr; + } +} } // namespace DistributedDB diff --git a/frameworks/libs/distributeddb/common/src/runtime_context_impl.h b/frameworks/libs/distributeddb/common/src/runtime_context_impl.h index 7ee478543f1d4e8a663e0cbe52a847c100552710..e79d23eee3db91ab9ccfcff3a0139bb23817a405 100644 --- a/frameworks/libs/distributeddb/common/src/runtime_context_impl.h +++ b/frameworks/libs/distributeddb/common/src/runtime_context_impl.h @@ -21,8 +21,8 @@ #include #include "auto_launch.h" -#include "evloop/include/ievent.h" -#include "evloop/include/ievent_loop.h" +#include "evloop/src/ievent.h" +#include "evloop/src/ievent_loop.h" #include "icommunicator_aggregator.h" #include "lock_status_observer.h" #include "task_pool.h" @@ -125,6 +125,8 @@ public: int SetPermissionConditionCallback(const PermissionConditionCallback &callback) override; std::map GetPermissionCheckParam(const DBProperties &properties) override; + + void StopTaskPool() override; private: static constexpr int MAX_TP_THREADS = 10; // max threads of the task pool. static constexpr int MIN_TP_THREADS = 1; // min threads of the task pool. diff --git a/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp b/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp index e1669b7f7487619e5a464d8aeb4cbe2430ed7fbe..82325e7c574f930fbd91d6a625b146266a2ae7a5 100644 --- a/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp +++ b/frameworks/libs/distributeddb/common/src/schema_negotiate.cpp @@ -213,12 +213,12 @@ int SchemaNegotiate::SerializeData(const RelationalSyncOpinion &opinions, Parcel (void)parcel.WriteString(MAGIC); (void)parcel.WriteUInt32(SYNC_OPINION_VERSION); (void)parcel.WriteUInt32(static_cast(opinions.size())); - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); for (const auto &it : opinions) { (void)parcel.WriteString(it.first); (void)parcel.WriteUInt32(it.second.permitSync); (void)parcel.WriteUInt32(it.second.requirePeerConvert); - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); } return parcel.IsError() ? -E_INVALID_ARGS : E_OK; } @@ -242,7 +242,7 @@ int SchemaNegotiate::DeserializeData(Parcel &parcel, RelationalSyncOpinion &opin } uint32_t opinionSize; (void)parcel.ReadUInt32(opinionSize); - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); static const uint32_t MAX_OPINION_SIZE = 1024; // max 1024 opinions if (parcel.IsError() || opinionSize > MAX_OPINION_SIZE) { return -E_INVALID_ARGS; @@ -257,7 +257,7 @@ int SchemaNegotiate::DeserializeData(Parcel &parcel, RelationalSyncOpinion &opin uint32_t requirePeerConvert; (void)parcel.ReadUInt32(requirePeerConvert); tableOpinion.requirePeerConvert = static_cast(requirePeerConvert); - (void)parcel.EightByteAlign(); + parcel.EightByteAlign(); opinion[tableName] = tableOpinion; } return parcel.IsError() ? -E_INVALID_ARGS : E_OK; diff --git a/frameworks/libs/distributeddb/communicator/include/communicator_aggregator.h b/frameworks/libs/distributeddb/communicator/include/communicator_aggregator.h index 30ca55f93cf29aecb48df41b115b33eca8e391ac..c3a31cdc1271b90bd2d3680f78464a12bb4bee26 100644 --- a/frameworks/libs/distributeddb/communicator/include/communicator_aggregator.h +++ b/frameworks/libs/distributeddb/communicator/include/communicator_aggregator.h @@ -16,20 +16,20 @@ #ifndef COMMUNICATORAGGREGATOR_H #define COMMUNICATORAGGREGATOR_H +#include +#include +#include #include #include #include -#include #include -#include -#include -#include "iadapter.h" -#include "parse_result.h" -#include "icommunicator.h" #include "frame_combiner.h" #include "frame_retainer.h" -#include "send_task_scheduler.h" +#include "iadapter.h" +#include "icommunicator.h" #include "icommunicator_aggregator.h" +#include "parse_result.h" +#include "send_task_scheduler.h" namespace DistributedDB { // Forward Declarations @@ -83,8 +83,8 @@ public: // Called by communicator to make itself really in work void ActivateCommunicator(const LabelType &commLabel); - // SerialBuffer surely is heap memory, CreateSendTask responsible for lifecycle - int CreateSendTask(const std::string &dstTarget, SerialBuffer *inBuff, FrameType inType, + // SerialBuffer surely is heap memory, ScheduleSendTask responsible for lifecycle + int ScheduleSendTask(const std::string &dstTarget, SerialBuffer *inBuff, FrameType inType, const TaskConfig &inConfig, const OnSendEnd &onEnd = nullptr); static void EnableCommunicatorNotFoundFeedback(bool isEnable); diff --git a/frameworks/libs/distributeddb/communicator/include/frame_combiner.h b/frameworks/libs/distributeddb/communicator/include/frame_combiner.h index 33124c497c406cbd976f569d8614838d7af6e688..d1ec81f82671369e3cfbdaee5aea45d27b8db7e6 100644 --- a/frameworks/libs/distributeddb/communicator/include/frame_combiner.h +++ b/frameworks/libs/distributeddb/communicator/include/frame_combiner.h @@ -16,20 +16,20 @@ #ifndef FRAME_COMBINER_H #define FRAME_COMBINER_H +#include #include #include -#include -#include "semaphore_utils.h" +#include "combine_status.h" #include "macro_utils.h" #include "parse_result.h" -#include "combine_status.h" #include "runtime_context.h" +#include "semaphore_utils.h" namespace DistributedDB { class SerialBuffer; // Forward Declarations struct CombineWork { - SerialBuffer *buffer; + SerialBuffer *buffer = nullptr; CombineStatus status; ParseResult frameInfo; }; diff --git a/frameworks/libs/distributeddb/communicator/include/frame_retainer.h b/frameworks/libs/distributeddb/communicator/include/frame_retainer.h index 259007369b33411447f08540796833d1b75c028e..a0b144087082fcda0f754da9890f2dbc5fdaee5d 100644 --- a/frameworks/libs/distributeddb/communicator/include/frame_retainer.h +++ b/frameworks/libs/distributeddb/communicator/include/frame_retainer.h @@ -27,16 +27,16 @@ namespace DistributedDB { class SerialBuffer; // Forward Declarations struct FrameInfo { - SerialBuffer *buffer; + SerialBuffer *buffer = nullptr; std::string srcTarget; LabelType commLabel; - uint32_t frameId; + uint32_t frameId = 0u; }; struct RetainWork { - SerialBuffer *buffer; - uint32_t frameId; - uint32_t remainTime; // in second + SerialBuffer *buffer = nullptr; + uint32_t frameId = 0u; + uint32_t remainTime = 0u; // in second }; class FrameRetainer { diff --git a/frameworks/libs/distributeddb/communicator/include/iadapter.h b/frameworks/libs/distributeddb/communicator/include/iadapter.h index f238114ca4b16f8c80e900dfa7e09465bfe47c02..d68916fa6cbbb99dbef38d2d1f6b250e993adc3e 100644 --- a/frameworks/libs/distributeddb/communicator/include/iadapter.h +++ b/frameworks/libs/distributeddb/communicator/include/iadapter.h @@ -16,10 +16,10 @@ #ifndef IADAPTER_H #define IADAPTER_H -#include #include #include #include +#include #include "communicator_type_define.h" #include "iprocess_communicator.h" diff --git a/frameworks/libs/distributeddb/communicator/include/icommunicator_aggregator.h b/frameworks/libs/distributeddb/communicator/include/icommunicator_aggregator.h index ee5c59dfda2febf2acba05f9bc6a86cf63eaf89b..06ae9e7c1e91e74188cf57540be44690eb309fe8 100644 --- a/frameworks/libs/distributeddb/communicator/include/icommunicator_aggregator.h +++ b/frameworks/libs/distributeddb/communicator/include/icommunicator_aggregator.h @@ -17,9 +17,9 @@ #define ICOMMUNICATORAGGREGATOR_H #include +#include "communicator_type_define.h" #include "iadapter.h" #include "ref_object.h" -#include "communicator_type_define.h" namespace DistributedDB { class ICommunicator; // Forward Declaration diff --git a/frameworks/libs/distributeddb/communicator/include/parse_result.h b/frameworks/libs/distributeddb/communicator/include/parse_result.h index 0e1278821a1492a77cf03e5780ac876fcb4a60ec..99d0cebd6137e708a567e4d7fc116d7f5a4c7729 100644 --- a/frameworks/libs/distributeddb/communicator/include/parse_result.h +++ b/frameworks/libs/distributeddb/communicator/include/parse_result.h @@ -16,8 +16,8 @@ #ifndef PARSE_RESULT_H #define PARSE_RESULT_H -#include #include +#include #include "communicator_type_define.h" namespace DistributedDB { diff --git a/frameworks/libs/distributeddb/communicator/include/send_task_scheduler.h b/frameworks/libs/distributeddb/communicator/include/send_task_scheduler.h index 8c1e3e12ec32d62d6dd55ad06ba06e00473b05fa..0725474062a4a2efc4239b2ef34b10ce39aa90d1 100644 --- a/frameworks/libs/distributeddb/communicator/include/send_task_scheduler.h +++ b/frameworks/libs/distributeddb/communicator/include/send_task_scheduler.h @@ -16,14 +16,14 @@ #ifndef SEND_TASK_SCHEDULER_H #define SEND_TASK_SCHEDULER_H -#include +#include #include +#include #include -#include #include -#include -#include "macro_utils.h" +#include #include "communicator_type_define.h" +#include "macro_utils.h" namespace DistributedDB { enum class TargetPolicy { @@ -34,14 +34,14 @@ enum class TargetPolicy { class SerialBuffer; // Forward Declaration struct SendTask { - SerialBuffer *buffer; + SerialBuffer *buffer = nullptr; std::string dstTarget; OnSendEnd onEnd; }; struct SendTaskInfo { - bool delayFlag; - Priority taskPrio; + bool delayFlag = false; + Priority taskPrio = Priority::LOW; }; using TaskListByTarget = std::map>; diff --git a/frameworks/libs/distributeddb/communicator/src/communicator.cpp b/frameworks/libs/distributeddb/communicator/src/communicator.cpp index e5c97f4126738d07594a7101a7fe5464d81b48c3..04b818e8185f8eb0e625d4d64315ad4f8fd87a52 100644 --- a/frameworks/libs/distributeddb/communicator/src/communicator.cpp +++ b/frameworks/libs/distributeddb/communicator/src/communicator.cpp @@ -116,7 +116,7 @@ int Communicator::SendMessage(const std::string &dstTarget, const Message *inMsg } int error = E_OK; // if error is not E_OK , null pointer will be returned - SerialBuffer *buffer = ProtocolProto::ToSerialBuffer(inMsg, error, extendHandle, false); + SerialBuffer *buffer = ProtocolProto::ToSerialBuffer(inMsg, extendHandle, false, error); extendHandle = nullptr; if (error != E_OK) { LOGE("[Comm][Send] Serial fail, label=%s, error=%d.", VEC_TO_STR(commLabel_), error); @@ -131,7 +131,7 @@ int Communicator::SendMessage(const std::string &dstTarget, const Message *inMsg } TaskConfig taskConfig {config.nonBlock, config.timeout, inMsg->GetPriority()}; - errCode = commAggrHandle_->CreateSendTask(dstTarget, buffer, FrameType::APPLICATION_MESSAGE, taskConfig, onEnd); + errCode = commAggrHandle_->ScheduleSendTask(dstTarget, buffer, FrameType::APPLICATION_MESSAGE, taskConfig, onEnd); if (errCode == E_OK) { // if ok, free inMsg, otherwise the caller should take over inMsg delete inMsg; @@ -226,7 +226,7 @@ void Communicator::TriggerVersionNegotiation(const std::string &dstTarget) } TaskConfig config{true, 0, Priority::HIGH}; - errCode = commAggrHandle_->CreateSendTask(dstTarget, buffer, FrameType::EMPTY, config); + errCode = commAggrHandle_->ScheduleSendTask(dstTarget, buffer, FrameType::EMPTY, config); if (errCode != E_OK) { LOGE("[Comm][TrigVer] Send empty frame fail, errCode=%d", errCode); // if send fails, free buffer, otherwise buffer will be taked over by comminucator aggregator @@ -259,7 +259,7 @@ void Communicator::TriggerUnknownMessageFeedback(const std::string &dstTarget, M } TaskConfig config{true, 0, Priority::HIGH}; - errCode = commAggrHandle_->CreateSendTask(dstTarget, buffer, FrameType::APPLICATION_MESSAGE, config); + errCode = commAggrHandle_->ScheduleSendTask(dstTarget, buffer, FrameType::APPLICATION_MESSAGE, config); if (errCode != E_OK) { LOGE("[Comm][TrigFeedback] Send unknown message feedback frame fail, errCode=%d", errCode); // if send fails, free buffer, otherwise buffer will be taked over by comminucator aggregator diff --git a/frameworks/libs/distributeddb/communicator/src/communicator.h b/frameworks/libs/distributeddb/communicator/src/communicator.h index c1f2ce39d4a8139905cfa57a6acf19e31b0e90be..fd9436ddfa66735c52262ada5bfd6d6382608d0f 100644 --- a/frameworks/libs/distributeddb/communicator/src/communicator.h +++ b/frameworks/libs/distributeddb/communicator/src/communicator.h @@ -16,16 +16,16 @@ #ifndef COMMUNICATOR_H #define COMMUNICATOR_H -#include -#include #include -#include +#include #include #include -#include -#include "serial_buffer.h" -#include "icommunicator.h" +#include +#include +#include #include "communicator_aggregator.h" +#include "icommunicator.h" +#include "serial_buffer.h" namespace DistributedDB { class Communicator : public ICommunicator { diff --git a/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp b/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp index 7c9151c9fc2d80e9abca2fd8d3b492f1ae4f2fe3..3cb9f9aab447e1014d37bdebba8e481af0ac4e28 100644 --- a/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp +++ b/frameworks/libs/distributeddb/communicator/src/communicator_aggregator.cpp @@ -16,12 +16,11 @@ #include "communicator_aggregator.h" #include - -#include "hash.h" #include "communicator.h" #include "communicator_linker.h" #include "db_common.h" #include "endian_convert.h" +#include "hash.h" #include "log_print.h" #include "protocol_proto.h" @@ -280,7 +279,7 @@ void DoOnSendEndByTaskIfNeed(const OnSendEnd &onEnd, int result) } } -int CommunicatorAggregator::CreateSendTask(const std::string &dstTarget, SerialBuffer *inBuff, +int CommunicatorAggregator::ScheduleSendTask(const std::string &dstTarget, SerialBuffer *inBuff, FrameType inType, const TaskConfig &inConfig, const OnSendEnd &onEnd) { if (inBuff == nullptr) { @@ -318,7 +317,7 @@ int CommunicatorAggregator::CreateSendTask(const std::string &dstTarget, SerialB std::lock_guard wakingLockGuard(wakingMutex_); wakingSignal_ = true; wakingCv_.notify_one(); - LOGI("[CommAggr][Create] Exit ok, thread=%s, frameId=%u", GetThreadId().c_str(), info.frameId); // Delete In Future + LOGI("[CommAggr][Create] Exit ok, thread=%s, frameId=%u", GetThreadId().c_str(), info.frameId); return E_OK; } @@ -343,9 +342,9 @@ void CommunicatorAggregator::SendDataRoutine() while (!shutdown_) { if (scheduler_.GetNoDelayTaskCount() == 0) { std::unique_lock wakingUniqueLock(wakingMutex_); - LOGI("[CommAggr][Routine] Send done and sleep."); // Delete In Future + LOGI("[CommAggr][Routine] Send done and sleep."); wakingCv_.wait(wakingUniqueLock, [this] { return this->wakingSignal_; }); - LOGI("[CommAggr][Routine] Send continue."); // Delete In Future + LOGI("[CommAggr][Routine] Send continue."); wakingSignal_ = false; continue; } @@ -366,7 +365,7 @@ void CommunicatorAggregator::SendDataRoutine() } // > std::vector>> eachPacket; - if (piecePackets.size() == 0) { + if (piecePackets.empty()) { // Case that no need to split a frame, just use original buffer as a packet std::pair tmpEntry = taskToSend.buffer->GetReadOnlyBytesForEntireBuffer(); std::pair> entry; @@ -392,8 +391,8 @@ void CommunicatorAggregator::SendPacketsAndDisposeTask(const SendTask &inTask, bool taskNeedFinalize = true; int errCode = E_OK; for (auto &entry : eachPacket) { - LOGI("[CommAggr][SendPackets] DoSendBytes, dstTarget=%s{private}, extendHeadLength=%u, totalLength=%u.", - inTask.dstTarget.c_str(), entry.second.first, entry.second.second); + LOGI("[CommAggr][SendPackets] DoSendBytes, dstTarget=%s{private}, extendHeadLength=%" PRIu32 + ", totalLength=%" PRIu32 ".", inTask.dstTarget.c_str(), entry.second.first, entry.second.second); ProtocolProto::DisplayPacketInformation(entry.first + entry.second.first, entry.second.second); errCode = adapterHandle_->SendBytes(inTask.dstTarget, entry.first, entry.second.second); if (errCode == -E_WAIT_RETRY) { @@ -479,7 +478,7 @@ void CommunicatorAggregator::NotifySendableToAllCommunicator() void CommunicatorAggregator::OnBytesReceive(const std::string &srcTarget, const uint8_t *bytes, uint32_t length, const std::string &userId) { - ProtocolProto::DisplayPacketInformation(bytes, length); // For debug, delete in the future + ProtocolProto::DisplayPacketInformation(bytes, length); ParseResult packetResult; int errCode = ProtocolProto::CheckAndParsePacket(srcTarget, bytes, length, packetResult); if (errCode != E_OK) { @@ -536,10 +535,7 @@ void CommunicatorAggregator::OnTargetChange(const std::string &target, bool isCo LOGE("[CommAggr][OnTarget] TargetOnline fail, target=%s{private}, errCode=%d.", target.c_str(), errCode); } } else { - int errCode = commLinker_->TargetOffline(target, relatedLabels); - if (errCode != E_OK) { - LOGE("[CommAggr][OnTarget] TargetOffline fail, target=%s{private}, errCode=%d.", target.c_str(), errCode); - } + commLinker_->TargetOffline(target, relatedLabels); } // All related communicator online or offline this target, no matter TargetOnline or TargetOffline fail or not std::lock_guard commMapLockGuard(commMapMutex_); @@ -782,7 +778,7 @@ void CommunicatorAggregator::GenerateLocalSourceId() // The localSourceId is std::atomic, so there is no concurrency risk uint64_t identityHash = Hash::HashFunc(identity); if (identityHash != localSourceId_) { - LOGI("[CommAggr][GenSrcId] identity=%s{private}, localSourceId=%llu.", identity.c_str(), ULL(identityHash)); + LOGI("[CommAggr][GenSrcId] identity=%s{private}, localSourceId=%" PRIu64, identity.c_str(), ULL(identityHash)); } localSourceId_ = identityHash; } @@ -808,7 +804,7 @@ void CommunicatorAggregator::TriggerVersionNegotiation(const std::string &dstTar } TaskConfig config{true, 0, Priority::HIGH}; - errCode = CreateSendTask(dstTarget, buffer, FrameType::EMPTY, config); + errCode = ScheduleSendTask(dstTarget, buffer, FrameType::EMPTY, config); if (errCode != E_OK) { LOGE("[CommAggr][TrigVer] Send empty frame fail, errCode=%d", errCode); // if send fails, free buffer, otherwise buffer will be taked over by SendTaskScheduler @@ -860,10 +856,10 @@ void CommunicatorAggregator::TriggerCommunicatorNotFoundFeedback(const std::stri } TaskConfig config{true, 0, Priority::HIGH}; - errCode = CreateSendTask(dstTarget, buffer, FrameType::APPLICATION_MESSAGE, config); + errCode = ScheduleSendTask(dstTarget, buffer, FrameType::APPLICATION_MESSAGE, config); if (errCode != E_OK) { LOGE("[CommAggr][TrigNotFound] Send communicator not found feedback frame fail, errCode=%d", errCode); - // if send fails, free buffer, otherwise buffer will be taked over by CreateSendTask + // if send fails, free buffer, otherwise buffer will be taked over by ScheduleSendTask delete buffer; buffer = nullptr; } diff --git a/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp b/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp index 59a1b77950d4870a0954c7e5c6840e103a509856..ab51b370d34c2d2a7361f70f99c9418ff2392bd8 100644 --- a/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp +++ b/frameworks/libs/distributeddb/communicator/src/communicator_linker.cpp @@ -14,12 +14,12 @@ */ #include "communicator_linker.h" -#include "hash.h" +#include "communicator_aggregator.h" #include "db_errno.h" +#include "hash.h" #include "log_print.h" -#include "protocol_proto.h" #include "platform_specific.h" -#include "communicator_aggregator.h" +#include "protocol_proto.h" namespace DistributedDB { namespace { @@ -51,7 +51,7 @@ void CommunicatorLinker::Initialize() } std::string curTimeStr = std::to_string(curTime); localDistinctValue_ = Hash::HashFunc(curTimeStr); - LOGI("[Linker][Init] curTime=%llu, distinct=%llu.", ULL(curTime), ULL(localDistinctValue_)); + LOGI("[Linker][Init] curTime=%" PRIu64 ", distinct=%" PRIu64 ".", ULL(curTime), ULL(localDistinctValue_)); } // Create async task to send out label_exchange and waiting for label_exchange_ack. @@ -73,7 +73,7 @@ int CommunicatorLinker::TargetOnline(const std::string &inTarget, std::set