From 5c71e74fa36a1f1f28f3bf068f66075ac4d378f1 Mon Sep 17 00:00:00 2001 From: "kaixuan.shao" Date: Mon, 21 Mar 2022 16:12:31 +0800 Subject: [PATCH 1/3] log fix --- .../distributeddatafwk/src/app_blob.cpp | 0 .../src/app_change_notification.cpp | 0 .../src/app_distributed_kv_data_manager.cpp | 0 .../app_distributed_kv_data_manager_impl.cpp | 20 ++-- .../src/app_kvstore_conflict_data_impl.cpp | 0 .../src/app_kvstore_impl.cpp | 55 +++++++++-- .../src/app_kvstore_result_set_impl.cpp | 3 + .../distributeddatafwk/src/blob.cpp | 0 .../src/change_notification.cpp | 13 ++- .../distributeddatafwk/src/data_query.cpp | 0 .../device_status_change_listener_client.cpp | 0 .../src/distributed_kv_data_manager.cpp | 8 +- .../idevice_status_change_listener_impl.cpp | 2 +- .../distributeddatafwk/src/ikvstore.cpp | 48 ++++----- .../src/ikvstore_data_service.cpp | 50 +++++++--- .../src/ikvstore_observer.cpp | 4 +- .../src/ikvstore_resultset.cpp | 16 +-- .../src/ikvstore_single.cpp | 98 ++++++++++++------- .../src/ikvstore_snapshot.cpp | 26 +++-- .../src/ikvstore_sync_callback.cpp | 2 +- .../distributeddatafwk/src/itypes_util.cpp | 21 ++++ .../distributeddatafwk/src/kvstore_client.cpp | 8 +- .../src/kvstore_client_death_observer.cpp | 0 .../src/kvstore_observer_client.cpp | 0 .../src/kvstore_resultset_client.cpp | 5 +- .../src/kvstore_service_death_notifier.cpp | 11 ++- .../src/kvstore_snapshot_client.cpp | 2 + .../src/kvstore_sync_callback_client.cpp | 2 +- .../src/single_kvstore_client.cpp | 15 ++- .../rdb/src/rdb_manager_impl.cpp | 7 +- .../innerkitsimpl/rdb/src/rdb_notifier.cpp | 2 + .../rdb/src/rdb_service_proxy.cpp | 15 +-- .../distributeddata/src/entry_point.cpp | 10 +- .../src/js_device_kv_store.cpp | 25 ++--- .../distributeddata/src/js_field_node.cpp | 3 + .../distributeddata/src/js_kv_manager.cpp | 21 ++-- .../distributeddata/src/js_kv_store.cpp | 37 ++++--- .../src/js_kv_store_resultset.cpp | 3 +- .../distributeddata/src/js_observer.cpp | 60 ------------ .../distributeddata/src/js_query.cpp | 9 ++ .../distributeddata/src/js_schema.cpp | 5 + .../src/js_single_kv_store.cpp | 23 ++--- .../distributeddata/src/js_util.cpp | 5 +- .../distributeddata/src/napi_queue.cpp | 2 + .../distributeddata/src/uv_queue.cpp | 2 +- .../adapter/account/src/account_delegate.cpp | 0 .../account/src/account_delegate_impl.cpp | 0 .../adapter/autils/src/constant.cpp | 0 .../adapter/autils/src/directory_utils.cpp | 0 .../adapter/autils/src/kv_scheduler.cpp | 0 .../autils/src/thread_pool/kv_store_task.cpp | 0 .../src/thread_pool/kv_store_thread.cpp | 6 ++ .../src/thread_pool/kv_store_thread_pool.cpp | 0 .../thread_pool/kv_store_thread_pool_impl.cpp | 0 .../test/unittest/kv_scheduler_test.cpp | 0 .../broadcaster/src/broadcast_sender.cpp | 0 .../broadcaster/src/broadcast_sender_impl.cpp | 0 .../communicator/src/app_device_handler.cpp | 0 .../communicator/src/app_pipe_handler.cpp | 0 .../adapter/communicator/src/app_pipe_mgr.cpp | 0 .../src/ark_communication_provider.cpp | 0 .../src/communication_provider_impl.cpp | 0 .../adapter/communicator/src/data_buffer.cpp | 8 -- .../src/process_communicator_impl.cpp | 0 .../src/softbus_adapter_standard.cpp | 2 +- .../adapter/dfx/src/dds_trace.cpp | 0 .../src/fault/communication_fault_impl.cpp | 0 .../dfx/src/fault/database_fault_impl.cpp | 0 .../adapter/dfx/src/fault/fault_reporter.cpp | 0 .../dfx/src/fault/runtime_fault_impl.cpp | 0 .../dfx/src/fault/service_fault_impl.cpp | 0 .../adapter/dfx/src/hiview_adapter.cpp | 0 .../adapter/dfx/src/reporter.cpp | 0 .../api_performance_statistic_impl.cpp | 0 .../src/statistic/database_statistic_impl.cpp | 0 .../dfx/src/statistic/statistic_reporter.cpp | 0 .../src/statistic/traffic_statistic_impl.cpp | 0 .../src/statistic/visit_statistic_impl.cpp | 0 .../src/client_permission_validator.cpp | 0 .../permission/src/permission_validator.cpp | 0 .../unittest/permission_validator_test.cpp | 0 .../adapter/utils/src/kvstore_utils.cpp | 0 .../app/src/backup_handler.cpp | 0 .../kvstore_flowctrl_manager.cpp | 0 .../app/src/kvstore_account_observer.cpp | 0 .../app/src/kvstore_app_accessor.cpp | 0 .../app/src/kvstore_app_manager.cpp | 2 +- .../app/src/kvstore_impl.cpp | 0 .../app/src/kvstore_meta_manager.cpp | 0 .../app/src/kvstore_resultset_impl.cpp | 0 .../app/src/kvstore_snapshot_impl.cpp | 0 .../app/src/kvstore_sync_manager.cpp | 0 .../app/src/kvstore_user_manager.cpp | 0 .../app/src/security/security.cpp | 1 + .../route_head_handler_impl.cpp | 16 +-- .../src/session_manager/session_manager.cpp | 16 +-- .../app/src/single_kvstore_impl.cpp | 0 .../app/src/uninstaller/uninstaller.cpp | 0 .../app/src/uninstaller/uninstaller_impl.cpp | 0 .../distributeddb/common/src/auto_launch.cpp | 75 +++++--------- .../common/src/param_check_utils.cpp | 1 + .../common/src/platform_specific.cpp | 2 +- .../communicator/src/communicator.cpp | 2 +- .../src/communicator_aggregator.cpp | 6 +- .../communicator/src/protocol_proto.cpp | 28 ++---- .../relational_store_delegate_impl.cpp | 2 +- .../storage/src/operation/database_oper.cpp | 2 + .../storage/src/sqlite/query_object.cpp | 88 +++++++---------- .../storage/src/sqlite/query_sync_object.cpp | 8 +- .../sqlite_relational_store_connection.cpp | 1 + .../sqlite_single_ver_database_upgrader.cpp | 4 +- .../sqlite_single_ver_natural_store.cpp | 8 +- ...te_single_ver_natural_store_connection.cpp | 28 +++--- ...single_ver_relational_storage_executor.cpp | 8 +- .../sqlite_single_ver_storage_engine.cpp | 13 --- .../sqlite_single_ver_storage_executor.cpp | 18 ++-- ...lite_single_ver_storage_executor_cache.cpp | 7 +- .../storage/src/sqlite/sqlite_utils.cpp | 64 +++++------- .../storage/src/storage_engine.cpp | 7 +- .../upgrader/single_ver_database_upgrader.cpp | 15 +-- .../distributeddb/syncer/src/ability_sync.cpp | 91 ++++++++++++----- .../syncer/src/commit_history_sync.cpp | 60 ++++++++++-- .../syncer/src/communicator_proxy.cpp | 3 + .../syncer/src/device_manager.cpp | 7 +- .../syncer/src/generic_syncer.cpp | 44 ++++++--- .../distributeddb/syncer/src/meta_data.cpp | 39 ++++++-- .../syncer/src/multi_ver_data_sync.cpp | 51 ++++++++-- .../src/multi_ver_sync_state_machine.cpp | 46 ++++++--- .../src/multi_ver_sync_task_context.cpp | 6 +- .../syncer/src/multi_ver_syncer.cpp | 9 +- .../src/query_sync_water_mark_helper.cpp | 22 ++++- .../src/single_ver_data_message_schedule.cpp | 2 +- .../syncer/src/single_ver_data_packet.cpp | 1 + .../syncer/src/value_slice_sync.cpp | 2 +- .../service/kv/user_delegate.cpp | 18 ++-- .../service/rdb/rdb_service_impl.cpp | 4 + .../service/rdb/rdb_service_stub.cpp | 6 +- .../service/rdb/rdb_syncer.cpp | 6 +- 138 files changed, 872 insertions(+), 621 deletions(-) mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_blob.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_change_notification.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_conflict_data_impl.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/blob.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/data_query.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/device_status_change_listener_client.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client_death_observer.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_observer_client.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp mode change 100644 => 100755 frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp delete mode 100644 frameworks/jskitsimpl/distributeddata/src/js_observer.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/account/src/account_delegate.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/constant.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/directory_utils.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/kv_scheduler.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_task.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/autils/test/unittest/kv_scheduler_test.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/broadcaster/src/broadcast_sender.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/broadcaster/src/broadcast_sender_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/app_device_handler.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/ark_communication_provider.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/communication_provider_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/data_buffer.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/process_communicator_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/dds_trace.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/reporter.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/permission/src/client_permission_validator.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/permission/src/permission_validator.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/permission/test/unittest/permission_validator_test.cpp mode change 100644 => 100755 services/distributeddataservice/adapter/utils/src/kvstore_utils.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/backup_handler.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_account_observer.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_app_accessor.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_app_manager.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_impl.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_meta_manager.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_resultset_impl.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_snapshot_impl.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_sync_manager.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/kvstore_user_manager.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/single_kvstore_impl.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/uninstaller/uninstaller.cpp mode change 100644 => 100755 services/distributeddataservice/app/src/uninstaller/uninstaller_impl.cpp diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_blob.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_blob.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_change_notification.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_change_notification.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp old mode 100644 new mode 100755 index afa655fa4..fc004122b --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp @@ -47,11 +47,12 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge std::lock_guard lck(storeMutex_); auto it = managers_.find(bundleName + userId); if (it != managers_.end()) { + ZLOGI("manager has been found"); return it->second; } std::string tempDataDir = dataDir; - ZLOGD("tempDataDir : %s", tempDataDir.c_str()); + ZLOGD("tempDataDir = %s", tempDataDir.c_str()); if (!ForceCreateDirectory(tempDataDir)) { ZLOGE("create directories %s failed", tempDataDir.c_str()); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_CREATE_DIR}; @@ -60,6 +61,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge } // default mode is 0755 if (!ChangeModeDirectory(tempDataDir, DistributedKv::Constant::DEFAULT_MODE)) { + ZLOGI("tempDataDir is default mode."); return nullptr; } @@ -69,7 +71,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge } auto status = DistributedDB::KvStoreDelegateManager::SetProcessLabel(appId + DEVICE_COLLABORATION_ABBRE, userId); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("delegate SetProcessLabel failed: %d.", static_cast(status)); + ZLOGE("delegate SetProcessLabel failed=%d.", static_cast(status)); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_PROCESS_LABEL}; Reporter::GetInstance()->ServiceFault()->Report(msg); return nullptr; @@ -78,7 +80,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge auto communicator = std::make_shared(); auto commStatus = DistributedDB::KvStoreDelegateManager::SetProcessCommunicator(communicator); if (commStatus != DistributedDB::DBStatus::OK) { - ZLOGW("set distributed db communicator failed."); + ZLOGW("set distributed db communicator failed=%d.", static_cast(status)); return nullptr; } @@ -90,7 +92,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge DistributedDB::KvStoreConfig kvStoreConfig { tempDataDir }; status = delegateManager->SetKvStoreConfig(kvStoreConfig); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("delegate SetKvStoreConfig failed: %d.", static_cast(status)); + ZLOGE("delegate SetKvStoreConfig failed=%d.", static_cast(status)); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_DATABASE_CONFIG}; Reporter::GetInstance()->ServiceFault()->Report(msg); delete delegateManager; @@ -166,7 +168,7 @@ Status AppDistributedKvDataManagerImpl::GetKvStore( Reporter::GetInstance()->ServiceFault()->Report(msg); }); - ZLOGI("get status: %d.", static_cast(status)); + ZLOGI("get status=%d.", static_cast(status)); return status; } @@ -201,7 +203,7 @@ Status AppDistributedKvDataManagerImpl::DeleteKvStore(const std::string &storeId ZLOGI("delete KVStore succeed."); return Status::SUCCESS; } - ZLOGE("delete KVStore failed."); + ZLOGE("delete KVStore failed, status=%d", static_cast(status)); return Status::ERROR; } @@ -214,10 +216,10 @@ Status AppDistributedKvDataManagerImpl::GetKvStoreDiskSize(const std::string &st } DistributedDB::DBStatus status = kvStoreDelegateManager_->GetKvStoreDiskSize(storeId, size); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to getStoreDiskSize, storeID: %s", storeId.c_str()); + ZLOGE("Failed to getStoreDiskSize, storeID: %s, status=%d", storeId.c_str(), static_cast(status)); return Status::ERROR; } - ZLOGI("end, size:%" PRIu64, size); + ZLOGI("end, size=%" PRIu64, size); return Status::SUCCESS; } @@ -233,6 +235,7 @@ Status AppDistributedKvDataManagerImpl::RegisterKvStoreCorruptionObserver( return Status::REPEATED_REGISTER; } if (kvStoreDelegateManager_ == nullptr) { + ZLOGE("kvStoreDelegateManager_ is nullptr."); return Status::ERROR; } corruptionObserver_ = observer; @@ -247,6 +250,7 @@ Status AppDistributedKvDataManagerImpl::RegisterKvStoreCorruptionObserver( DistributedDB::SecurityOption AppDistributedKvDataManagerImpl::ConvertSecurityLevel(int securityLevel) { if (securityLevel < SecurityLevel::NO_LABEL || securityLevel > SecurityLevel::S4) { + ZLOGD("SecurityLevel not correct"); return {SecurityLevel::NO_LABEL, DistributedDB::ECE}; } switch (securityLevel) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_conflict_data_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_conflict_data_impl.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp old mode 100644 new mode 100755 index 2ce544b7a..7e4080a71 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp @@ -86,7 +86,7 @@ Status AppKvStoreImpl::Put(const WriteOptions &options, const Key &key, const Va Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGW("put failed. status: %d.", static_cast(status)); + ZLOGE("put failed. status=%d.", static_cast(status)); return ConvertErrorCode(status); } @@ -111,7 +111,7 @@ Status AppKvStoreImpl::Delete(const WriteOptions &options, const Key &key) Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGW("failed status: %d.", static_cast(status)); + ZLOGE("failed status=%d.", static_cast(status)); return ConvertErrorCode(status); } @@ -124,6 +124,7 @@ Status AppKvStoreImpl::Get(const ReadOptions &options, const Key &key, Value &va ZLOGD("start"); auto trimmedKey = DistributedKv::Constant::TrimCopy>(key.Data()); if (trimmedKey.size() == 0 || trimmedKey.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { + ZLOGE("trimmedKey size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKey = trimmedKey; @@ -142,6 +143,7 @@ Status AppKvStoreImpl::Get(const ReadOptions &options, const Key &key, Value &va Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } + ZLOGE("get key-value error, errCode=%d", status); return ConvertErrorCode(status); } @@ -154,6 +156,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr ZLOGD("start."); auto trimmedPrefix = DistributedKv::Constant::TrimCopy>(prefixKey.Data()); if (trimmedPrefix.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { + ZLOGE("trimmedPrefix size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKeyPrefix = trimmedPrefix; @@ -161,7 +164,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr DistributedDB::DBStatus status = kvStoreNbDelegate_->GetEntries(tmpKeyPrefix, dbEntries); if (status == DistributedDB::DBStatus::OK) { entries.reserve(dbEntries.size()); - ZLOGD("vector size: %zu status: %d.", dbEntries.size(), static_cast(status)); + ZLOGD("vector size=%zu status=%d.", dbEntries.size(), static_cast(status)); for (auto const &dbEntry : dbEntries) { Key tmpKey(dbEntry.key); Value tmpValue(dbEntry.value); @@ -169,6 +172,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr } return Status::SUCCESS; } + ZLOGE("get entries error, errCode=%d", status); return ConvertErrorCode(status); } @@ -178,6 +182,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, AppKvStoreResultSet *&re ZLOGD("start."); auto trimmedPrefix = DistributedKv::Constant::TrimCopy>(prefixKey.Data()); if (trimmedPrefix.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { + ZLOGE("trimmedPrefix size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKeyPrefix = trimmedPrefix; @@ -186,41 +191,50 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, AppKvStoreResultSet *&re if (status == DistributedDB::DBStatus::OK) { resultSet = new (std::nothrow) AppKvStoreResultSetImpl(dbResultSet, kvStoreNbDelegate_); if (resultSet == nullptr) { - ZLOGW("new resultSet failed."); + ZLOGE("new resultSet failed."); return Status::ERROR; } return Status::SUCCESS; } + ZLOGE("get entries error, errCode=%d", status); return ConvertErrorCode(status); } // Close the result set returned by GetEntries(). Status AppKvStoreImpl::CloseResultSet(AppKvStoreResultSet *&resultSet) { + ZLOGD("start."); if (resultSet == nullptr) { + ZLOGE("resultSet is nullptr"); return Status::INVALID_ARGUMENT; } if (resultSet->Close() == Status::SUCCESS) { + ZLOGD("successful."); delete resultSet; resultSet = nullptr; return Status::SUCCESS; } + ZLOGE("close resultSet error."); return Status::ERROR; } // Close this kvstore in KvStoreDelegateManager. This method is called before this store object destruct. Status AppKvStoreImpl::Close(DistributedDB::KvStoreDelegateManager *kvStoreDelegateManager) { + ZLOGD("start."); if (kvStoreDelegateManager == nullptr) { + ZLOGE("kvStoreDelegateManager is nullptr"); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus status = kvStoreDelegateManager->CloseKvStore(kvStoreNbDelegate_); if (status == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); VisitStat vs { appId_, __FUNCTION__ }; Reporter::GetInstance()->VisitStatistic()->Report(vs); return Status::SUCCESS; } + ZLOGE("close KvStore error, errCode=%d", status); return Status::ERROR; } @@ -270,7 +284,7 @@ Status AppKvStoreImpl::Sync(const std::vector &deviceIds, SyncMode callback(resultMap); }); - ZLOGD("end: %d", static_cast(status)); + ZLOGD("end=%d", static_cast(status)); Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (status == DistributedDB::DBStatus::OK) { return Status::SUCCESS; @@ -293,6 +307,7 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr { ZLOGD("start."); if (observer == nullptr) { + ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus dbStatus; @@ -306,6 +321,7 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr std::lock_guard lock(localObserverMapMutex_); bool alreadySubscribed = (localObserverMap_.find(observer) != localObserverMap_.end()); if (alreadySubscribed) { + ZLOGD("store alreadly subscribe."); delete nbObserver; return Status::STORE_ALREADY_SUBSCRIBE; } @@ -313,12 +329,14 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr dbStatus = kvStoreNbDelegate_->RegisterObserver( emptyKey, DistributedDB::ObserverMode::OBSERVER_CHANGES_LOCAL_ONLY, nbObserver); if (dbStatus == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); localObserverMap_.insert(std::pair(observer, nbObserver)); } } else { std::lock_guard lock(syncedObserverMapMutex_); bool alreadySubscribed = (syncedObserverMap_.find(observer) != syncedObserverMap_.end()); if (alreadySubscribed) { + ZLOGD("store alreadly subscribe."); delete nbObserver; return Status::STORE_ALREADY_SUBSCRIBE; } @@ -338,16 +356,20 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr } Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (dbStatus == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); return Status::SUCCESS; } delete nbObserver; if (dbStatus == DistributedDB::DBStatus::INVALID_ARGS) { + ZLOGE("Invalid args."); return Status::INVALID_ARGUMENT; } if (dbStatus == DistributedDB::DBStatus::DB_ERROR) { + ZLOGE("db error."); return Status::DB_ERROR; } + ZLOGE("error."); return Status::ERROR; } @@ -365,6 +387,7 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs { ZLOGD("start."); if (observer == nullptr) { + ZLOGE("observer is nullptr."); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus dbStatus; @@ -372,6 +395,7 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs std::lock_guard lock(localObserverMapMutex_); auto nbObserver = localObserverMap_.find(observer); if (nbObserver == localObserverMap_.end()) { + ZLOGD("store not subscribe"); return Status::STORE_NOT_SUBSCRIBE; } dbStatus = kvStoreNbDelegate_->UnRegisterObserver(nbObserver->second); @@ -383,6 +407,7 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs std::lock_guard lock(syncedObserverMapMutex_); auto nbObserver = syncedObserverMap_.find(observer); if (nbObserver == syncedObserverMap_.end()) { + ZLOGD("store not subscribe."); return Status::STORE_NOT_SUBSCRIBE; } dbStatus = kvStoreNbDelegate_->UnRegisterObserver(nbObserver->second); @@ -393,14 +418,18 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs } Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (dbStatus == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); return Status::SUCCESS; } if (dbStatus == DistributedDB::DBStatus::NOT_FOUND) { + ZLOGE("store not subscribe.."); return Status::STORE_NOT_SUBSCRIBE; } if (dbStatus == DistributedDB::DBStatus::INVALID_ARGS) { + ZLOGE("invalid args."); return Status::INVALID_ARGUMENT; } + ZLOGE("db error."); return Status::ERROR; } @@ -411,6 +440,7 @@ Status AppKvStoreImpl::RemoveDeviceData(const std::string &device) if (status == DistributedDB::DBStatus::OK) { return Status::SUCCESS; } + ZLOGW("RemoveDeviceData error, errCode=%d", status); return Status::ERROR; } @@ -429,6 +459,7 @@ Status AppKvStoreImpl::SetConflictResolutionPolicy( callback(appConflictDataImpl); }); if (dbStatus != DistributedDB::DBStatus::OK) { + ZLOGE("error, status=%d", dbStatus); return Status::DB_ERROR; } return Status::SUCCESS; @@ -437,6 +468,7 @@ Status AppKvStoreImpl::SetConflictResolutionPolicy( void AppKvStoreImpl::FormKvStoreConflictEntry(const DistributedDB::KvStoreNbConflictData &data, KvStoreConflictEntry &kvstoreConflictEntry) { + ZLOGD("start."); kvstoreConflictEntry.type = data.GetType(); DistributedDB::Key dbKey; data.GetKey(dbKey); @@ -452,6 +484,7 @@ void AppKvStoreImpl::FormKvStoreConflictData(const DistributedDB::KvStoreNbConfl DistributedDB::KvStoreNbConflictData::ValueType type, KvStoreConflictData &kvStoreConflictData) { + ZLOGD("start."); DistributedDB::DBStatus dbStatus; kvStoreConflictData.isLocal = data.IsNative(type); kvStoreConflictData.isDeleted = data.IsDeleted(type); @@ -459,7 +492,7 @@ void AppKvStoreImpl::FormKvStoreConflictData(const DistributedDB::KvStoreNbConfl DistributedDB::Value dbValue; dbStatus = data.GetValue(type, dbValue); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to handle conflict, error: bad conflict data"); + ZLOGE("Failed to handle conflict, error: bad conflict data status=%d", dbStatus); kvStoreConflictData.status = Status::DB_ERROR; return; } @@ -473,17 +506,18 @@ Status AppKvStoreImpl::Export(const std::string &filePath, const std::vectorExport(filePath, password); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to export, path:%s", filePath.c_str()); + ZLOGE("Failed to export, path=%s, status=%d", filePath.c_str(), dbStatus); return Status::DB_ERROR; } ZLOGD("export end"); @@ -494,17 +528,18 @@ Status AppKvStoreImpl::Import(const std::string &filePath, const std::vectorImport(filePath, password); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to export, path:%s", filePath.c_str()); + ZLOGE("Failed to export, path=%s, status=%d", filePath.c_str(), dbStatus); return Status::DB_ERROR; } ZLOGD("Import end"); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp old mode 100644 new mode 100755 index 0cecd9a0f..0c76ba3c3 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp @@ -17,6 +17,7 @@ #include "app_kvstore_result_set_impl.h" #include "app_types.h" +#include "log_print.h" namespace OHOS { namespace AppDistributedKv { @@ -110,9 +111,11 @@ bool AppKvStoreResultSetImpl::IsAfterLast() const Status AppKvStoreResultSetImpl::GetEntry(Entry &entry) const { if (kvStoreResultSet_ == nullptr) { + ZLOGD("kvStoreResultSet_ is nullptr"); return Status::ERROR; } if (GetCount() == 0) { + ZLOGD("count is zero"); return Status::KEY_NOT_FOUND; } DistributedDB::Entry dbEntry; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/blob.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/blob.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp index 1a7a14a09..8d57dc012 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp @@ -58,35 +58,42 @@ bool ChangeNotification::IsClear() const bool ChangeNotification::Marshalling(Parcel &parcel) const { if (!parcel.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGE("SetMaxCapacity MAX_IPC_CAPACITY failed."); return false; } int32_t lenInsert = static_cast(insertEntries_.size()); if (!parcel.WriteInt32(lenInsert)) { + ZLOGE("WriteInt32 lenInsert failed."); return false; } for (const auto &entry : insertEntries_) { if (!parcel.WriteParcelable(&entry)) { + ZLOGE("WriteParcelable insertEntries_ entrys failed."); return false; } } int32_t lenUpdate = static_cast(updateEntries_.size()); if (!parcel.WriteInt32(lenUpdate)) { + ZLOGE("WriteInt32 lenUpdate failed."); return false; } for (const auto &entry : updateEntries_) { if (!parcel.WriteParcelable(&entry)) { + ZLOGE("WriteParcelable updateEntries_ entrys failed."); return false; } } int32_t lenDelete = static_cast(deleteEntries_.size()); if (!parcel.WriteInt32(lenDelete)) { + ZLOGE("WriteInt32 lenDelete failed."); return false; } for (const auto &entry : deleteEntries_) { if (!parcel.WriteParcelable(&entry)) { + ZLOGE("WriteParcelable deleteEntries_ entrys failed."); return false; } } @@ -106,7 +113,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenInsert = parcel.ReadInt32(); if (lenInsert < 0) { - ZLOGE("lenInsert is %d", lenInsert); + ZLOGE("lenInsert = %d", lenInsert); return nullptr; } for (int i = 0; i < lenInsert; i++) { @@ -121,7 +128,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenUpdate = parcel.ReadInt32(); if (lenUpdate < 0) { - ZLOGE("lenUpdate is %d", lenUpdate); + ZLOGE("lenUpdate = %d", lenUpdate); return nullptr; } for (int i = 0; i < lenUpdate; i++) { @@ -136,7 +143,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenDelete = parcel.ReadInt32(); if (lenDelete < 0) { - ZLOGE("lenDelete is %d", lenDelete); + ZLOGE("lenDelete = %d", lenDelete); return nullptr; } for (int i = 0; i < lenDelete; i++) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/data_query.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/data_query.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/device_status_change_listener_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/device_status_change_listener_client.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp index 58894cf8a..6385d6aaf 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp @@ -60,13 +60,13 @@ Status DistributedKvDataManager::GetKvStore(const Options &options, const AppId status = kvDataServiceProxy->GetKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (status == Status::RECOVER_SUCCESS) { - ZLOGE("proxy recover success: %d", static_cast(status)); + ZLOGE("proxy recover success=%d", static_cast(status)); kvStore = std::make_shared(std::move(proxyTmp), storeIdTmp); return status; } if (status != Status::SUCCESS) { - ZLOGE("proxy return error: %d", static_cast(status)); + ZLOGE("proxy return error=%d", static_cast(status)); return status; } @@ -103,13 +103,13 @@ Status DistributedKvDataManager::GetSingleKvStore(const Options &options, const status = kvDataServiceProxy->GetSingleKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (status == Status::RECOVER_SUCCESS) { - ZLOGE("proxy recover success: %d", static_cast(status)); + ZLOGE("proxy recover success=%d", static_cast(status)); singleKvStore = std::make_shared(std::move(proxyTmp), storeIdTmp); return status; } if (status != Status::SUCCESS) { - ZLOGE("proxy return error: %d", static_cast(status)); + ZLOGE("proxy return error=%d", static_cast(status)); return status; } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp old mode 100644 new mode 100755 index 2bb53ec31..9d6d3d1cc --- a/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp @@ -42,7 +42,7 @@ void DeviceStatusChangeListenerProxy::OnChange(const DeviceInfo &results, const MessageOption mo { MessageOption::TF_ASYNC }; int error = Remote()->SendRequest(ONCHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error %d", error); + ZLOGW("SendRequest failed, error=%d", error); } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp old mode 100644 new mode 100755 index 64500b51c..9609d6051 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp @@ -45,6 +45,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, std::function)> callback) { if (observer == nullptr) { + ZLOGW("observer is nullptr"); callback(Status::INVALID_ARGUMENT, nullptr); return; } @@ -62,7 +63,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETKVSTORESNAPSHOT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); callback(Status::IPC_ERROR, nullptr); return; } @@ -70,6 +71,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, if (status == Status::SUCCESS) { sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject is nullptr"); callback(status, nullptr); return; } @@ -100,7 +102,7 @@ Status KvStoreImplProxy::ReleaseKvStoreSnapshot(sptr kvSto MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(RELEASEKVSTORESNAPSHOT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -133,7 +135,7 @@ Status KvStoreImplProxy::Put(const Key &key, const Value &value) MessageOption mo { MessageOption::TF_SYNC }; int error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed with error code %d", error); + ZLOGW("SendRequest failed with error code=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -158,7 +160,7 @@ Status KvStoreImplProxy::Put(const Key &key, const Value &value) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -183,6 +185,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) int64_t bufferSize = 0; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { + ZLOGW("entrty size too long."); return Status::INVALID_ARGUMENT; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -200,6 +203,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) } MessageOption mo { MessageOption::TF_SYNC }; if (Remote()->SendRequest(PUTBATCH, data, reply, mo) != 0) { + ZLOGW("Remote SendRequest failed."); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -229,7 +233,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUTBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -249,7 +253,7 @@ Status KvStoreImplProxy::Delete(const Key &key) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -283,7 +287,7 @@ Status KvStoreImplProxy::DeleteBatch(const std::vector &keys) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -299,7 +303,7 @@ Status KvStoreImplProxy::Clear() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLEAR, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -315,7 +319,7 @@ Status KvStoreImplProxy::StartTransaction() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTTRANSACTION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -331,7 +335,7 @@ Status KvStoreImplProxy::Commit() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(COMMIT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -347,7 +351,7 @@ Status KvStoreImplProxy::Rollback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(ROLLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -374,7 +378,7 @@ Status KvStoreImplProxy::SubscribeKvStore(const SubscribeType subscribeType, spt MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -383,6 +387,7 @@ Status KvStoreImplProxy::SubscribeKvStore(const SubscribeType subscribeType, spt Status KvStoreImplProxy::UnSubscribeKvStore(const SubscribeType subscribeType, sptr observer) { if (observer == nullptr) { + ZLOGW("observer is invalid."); return Status::INVALID_ARGUMENT; } @@ -400,7 +405,7 @@ Status KvStoreImplProxy::UnSubscribeKvStore(const SubscribeType subscribeType, s MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -410,6 +415,7 @@ int32_t KvStoreImplStub::GetKvStoreSnapshotOnRemote(MessageParcel &data, Message { sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("remote is nullptr."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write obj failed."); return -1; @@ -460,11 +466,12 @@ int32_t KvStoreImplStub::PutOnRemoteRequest(MessageParcel &data, MessageParcel & return -1; } const int bufferSize = data.ReadInt32(); - ZLOGD("bufferSize %d", bufferSize); + ZLOGD("bufferSize=%d", bufferSize); if (bufferSize < Constant::SWITCH_RAW_DATA_SIZE) { sptr key = data.ReadParcelable(); sptr value = data.ReadParcelable(); if (key == nullptr || value == nullptr) { + ZLOGW("key or value is nullptr."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write key or val status failed."); return -1; @@ -473,7 +480,7 @@ int32_t KvStoreImplStub::PutOnRemoteRequest(MessageParcel &data, MessageParcel & } Status status = Put(*key, *value); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write ret status failed."); + ZLOGW("write *ret status failed."); return -1; } return 0; @@ -513,9 +520,8 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar } int len = data.ReadInt32(); if (len < 0) { - ZLOGW("invalid status. len %d", len); + ZLOGW("invalid status. len=%d", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("write putbatch failed."); return -1; } return 0; @@ -528,7 +534,6 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (entry == nullptr) { ZLOGW("putbatch got null entry pointer"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { - ZLOGW("write putbatch failed."); return -1; } return 0; @@ -547,7 +552,6 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (buffer == nullptr) { ZLOGW("buffer is null"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { - ZLOGW("write putbatch big failed."); return -1; } return 0; @@ -563,7 +567,6 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (!success) { ZLOGW("get key or value failed"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { - ZLOGW("write putbatch big failed."); return -1; } return 0; @@ -582,7 +585,6 @@ int32_t KvStoreImplStub::DeleteOnRemoteRequest(MessageParcel &data, MessageParce if (key == nullptr) { ZLOGW("key nullptr after ipc"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("write delete failed."); return -1; } return 0; @@ -598,7 +600,7 @@ int32_t KvStoreImplStub::DeleteBatchOnRemoteRequest(MessageParcel &data, Message { int len = data.ReadInt32(); if (len < 0) { - ZLOGW("len %d invalid after ipc", len); + ZLOGW("len=%d invalid after ipc", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write delete failed."); return -1; @@ -629,6 +631,7 @@ int32_t KvStoreImplStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessagePa { int32_t type = data.ReadInt32(); if (type < 0) { + ZLOGW("type=%d invalid after ipc", type); return -1; } SubscribeType subscribeType = static_cast(type); @@ -652,6 +655,7 @@ int32_t KvStoreImplStub::UnSubscribeKvStoreOnRemote(MessageParcel &data, Message { int32_t type = data.ReadInt32(); if (type < 0) { + ZLOGW("type=%d invalid after ipc", type); return -1; } SubscribeType subscribeType = static_cast(type); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp old mode 100644 new mode 100755 index 068c6a147..8e126f6c2 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp @@ -36,7 +36,7 @@ KvStoreDataServiceProxy::KvStoreDataServiceProxy(const sptr &impl Status KvStoreDataServiceProxy::GetKvStore(const Options &options, const AppId &appId, const StoreId &storeId, std::function)> callback) { - ZLOGI("%s %s", appId.appId.c_str(), storeId.storeId.c_str()); + ZLOGI("appId=%s storeId=%s", appId.appId.c_str(), storeId.storeId.c_str()); MessageParcel data; MessageParcel reply; @@ -86,7 +86,7 @@ Status KvStoreDataServiceProxy::GetKvStore(const Options &options, const AppId & Status KvStoreDataServiceProxy::GetSingleKvStore(const Options &options, const AppId &appId, const StoreId &storeId, std::function)> callback) { - ZLOGI("%s %s", appId.appId.c_str(), storeId.storeId.c_str()); + ZLOGI("appId=%s storeId=%s", appId.appId.c_str(), storeId.storeId.c_str()); MessageParcel data; MessageParcel reply; if (!data.WriteInterfaceToken(KvStoreDataServiceProxy::GetDescriptor())) { @@ -121,7 +121,7 @@ Status KvStoreDataServiceProxy::GetSingleKvStore(const Options &options, const A MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETSINGLEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -154,7 +154,7 @@ void KvStoreDataServiceProxy::GetAllKvStoreId(const AppId &appId, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETALLKVSTOREID, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); callback(Status::IPC_ERROR, storeIds); return; } @@ -183,7 +183,7 @@ Status KvStoreDataServiceProxy::CloseKvStore(const AppId &appId, const StoreId & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -205,7 +205,7 @@ Status KvStoreDataServiceProxy::CloseAllKvStore(const AppId &appId) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSEALLKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -227,7 +227,7 @@ Status KvStoreDataServiceProxy::DeleteKvStore(const AppId &appId, const StoreId MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -249,7 +249,7 @@ Status KvStoreDataServiceProxy::DeleteAllKvStore(const AppId &appId) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEALLKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -273,13 +273,14 @@ Status KvStoreDataServiceProxy::RegisterClientDeathObserver(const AppId &appId, return Status::IPC_ERROR; } } else { + ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REGISTERCLIENTDEATHOBSERVER, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -296,7 +297,7 @@ Status KvStoreDataServiceProxy::GetLocalDevice(OHOS::DistributedKv::DeviceInfo & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETLOCALDEVICE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -321,7 +322,7 @@ Status KvStoreDataServiceProxy::GetDeviceList(std::vector &deviceInf MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETDEVICELIST, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -353,16 +354,18 @@ Status KvStoreDataServiceProxy::StartWatchDeviceChange(sptrAsObject().GetRefPtr())) { + ZLOGW("WriteRemoteObject observer failed."); return Status::IPC_ERROR; } } else { + ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageParcel reply; MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTWATCHDEVICECHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -377,16 +380,18 @@ Status KvStoreDataServiceProxy::StopWatchDeviceChange(sptrAsObject().GetRefPtr())) { + ZLOGW("WriteRemoteObject observer failed."); return Status::IPC_ERROR; } } else { + ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageParcel reply; MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STOPWATCHDEVICECHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -405,7 +410,7 @@ sptr KvStoreDataServiceProxy::GetRdbService() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GET_RDB_SERVICE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %{public}d", error); + ZLOGE("SendRequest returned=%{public}d", error); return nullptr; } auto remoteObject = reply.ReadRemoteObject(); @@ -444,6 +449,7 @@ int32_t KvStoreDataServiceStub::GetKvStoreOnRemote(MessageParcel &data, MessageP Status status = GetKvStore(options, appId, storeId, [&proxyTmp](sptr proxy) { proxyTmp = std::move(proxy); }); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } if (proxyTmp == nullptr) { @@ -469,10 +475,12 @@ int32_t KvStoreDataServiceStub::GetAllKvStoreIdOnRemote(MessageParcel &data, Mes }); if (!reply.WriteStringVector(storeIdList)) { + ZLOGW("write storeIdList failed."); return -1; } if (!reply.WriteInt32(static_cast(statusTmp))) { + ZLOGW("write statusTmp failed."); return -1; } return 0; @@ -483,15 +491,18 @@ int32_t KvStoreDataServiceStub::GetDeviceListOnRemote(MessageParcel &data, Messa DeviceFilterStrategy strategy = static_cast(data.ReadInt32()); Status status = GetDeviceList(infos, strategy); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } if (status == Status::SUCCESS) { if (!reply.WriteInt32(infos.size())) { + ZLOGW("write infos failed."); return -1; } for (DeviceInfo const &info : infos) { if (!reply.WriteString(info.deviceId) || !reply.WriteString(info.deviceName) || !reply.WriteString(info.deviceType)) { + ZLOGW("write info failed."); return -1; } } @@ -512,6 +523,7 @@ int32_t KvStoreDataServiceStub::StartWatchDeviceChangeOnRemote(MessageParcel &da sptr observerProxy = iface_cast(remote); Status status = StartWatchDeviceChange(std::move(observerProxy), strategy); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -529,6 +541,7 @@ int32_t KvStoreDataServiceStub::StopWatchDeviceChangeOnRemote(MessageParcel &dat sptr observerProxy = iface_cast(remote); Status status = StopWatchDeviceChange(std::move(observerProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -562,10 +575,12 @@ int32_t KvStoreDataServiceStub::GetSingleKvStoreOnRemote(MessageParcel &data, Me Status status = GetSingleKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } if (status == Status::SUCCESS && proxyTmp != nullptr) { if (!reply.WriteRemoteObject(proxyTmp->AsObject().GetRefPtr())) { + ZLOGW("WriteRemoteObject proxyTmp failed."); return -1; } } @@ -578,6 +593,7 @@ int32_t KvStoreDataServiceStub::CloseKvStoreOnRemote(MessageParcel &data, Messag StoreId storeId = { Constant::TrimCopy(data.ReadString())}; Status status = CloseKvStore(appId, storeId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -588,6 +604,7 @@ int32_t KvStoreDataServiceStub::CloseAllKvStoreOnRemote(MessageParcel &data, Mes AppId appId = { Constant::TrimCopy(data.ReadString())}; Status status = CloseAllKvStore(appId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -599,6 +616,7 @@ int32_t KvStoreDataServiceStub::DeleteKvStoreOnRemote(MessageParcel &data, Messa StoreId storeId = { Constant::TrimCopy(data.ReadString())}; Status status = DeleteKvStore(appId, storeId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -609,6 +627,7 @@ int32_t KvStoreDataServiceStub::DeleteAllKvStoreOnRemote(MessageParcel &data, Me AppId appId = { Constant::TrimCopy(data.ReadString())}; Status status = DeleteAllKvStore(appId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -619,10 +638,12 @@ int32_t KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote(MessageParce AppId appId = { Constant::TrimCopy(data.ReadString())}; sptr kvStoreClientDeathObserverProxy = data.ReadRemoteObject(); if (kvStoreClientDeathObserverProxy == nullptr) { + ZLOGW("kvStoreClientDeathObserverProxy is nullptr."); return -1; } Status status = RegisterClientDeathObserver(appId, std::move(kvStoreClientDeathObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -634,6 +655,7 @@ int32_t KvStoreDataServiceStub::GetLocalDeviceOnRemote(MessageParcel &data, Mess Status status = GetLocalDevice(info); if (!reply.WriteInt32(static_cast(status)) || !reply.WriteString(info.deviceId) || !reply.WriteString(info.deviceName) || !reply.WriteString(info.deviceType)) { + ZLOGW("write failed."); return -1; } return 0; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp index 1ed10b7cc..e748ebe46 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp @@ -125,7 +125,7 @@ void KvStoreObserverProxy::OnChange(const ChangeNotification &changeNotification MessageOption mo { MessageOption::TF_WAIT_TIME }; int error = Remote()->SendRequest(ONCHANGE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest failed, error %d", error); + ZLOGE("SendRequest failed, error=%d", error); } } @@ -154,7 +154,7 @@ bool ReadListFromBuf(MessageParcel &data, std::vector &entries) { int len = data.ReadInt32(); if (len < 0) { - ZLOGE("read onChangeLen failed len %d", len); + ZLOGE("read onChangeLen failed len=%d", len); return false; } int bufferSize = data.ReadInt32(); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp old mode 100644 new mode 100755 index 72dd7171e..d366654d3 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp @@ -79,12 +79,13 @@ bool KvStoreResultSetProxy::Move(int offset) } bool ret = data.WriteInt32(offset); if (!ret) { + ZLOGE("write offset failed"); return ret; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(MOVE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d, code=%d", error, MOVE); + ZLOGW("SendRequest returned=%d, code=%d", error, MOVE); return false; } return reply.ReadBool(); @@ -99,12 +100,13 @@ bool KvStoreResultSetProxy::MoveToPosition(int position) } bool ret = data.WriteInt32(position); if (!ret) { + ZLOGE("write position failed"); return ret; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(MOVETOPOSITION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d, code=%d", error, MOVETOPOSITION); + ZLOGW("SendRequest returned=%d, code=%d", error, MOVETOPOSITION); return false; } return reply.ReadBool(); @@ -147,13 +149,13 @@ Status KvStoreResultSetProxy::GetEntry(Entry &entry) ZLOGI("start"); int32_t error = Remote()->SendRequest(GETENTRY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } sptr valueTmp = reply.ReadParcelable(); @@ -173,7 +175,7 @@ int KvStoreResultSetProxy::SendRequest(uint32_t code) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(code, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d, code=%d", error, code); + ZLOGW("SendRequest returned=%d, code=%d", error, code); return -1; } return reply.ReadInt32(); @@ -189,7 +191,7 @@ bool KvStoreResultSetProxy::SendRequestRetBool(uint32_t code) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(code, data, reply, mo); if (error != 0) { - ZLOGW("SendRequestRetBool returned %d, code=%d", error, code); + ZLOGW("SendRequestRetBool returned=%d, code=%d", error, code); return false; } return reply.ReadBool(); @@ -317,7 +319,7 @@ int KvStoreResultSetStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me return GetEntryOnRemote(reply); } default: { - ZLOGW("OnRemoteRequest default %d", code); + ZLOGW("OnRemoteRequest default=%d", code); MessageOption mo { MessageOption::TF_SYNC }; return IPCObjectStub::OnRemoteRequest(code, data, reply, mo); } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp old mode 100644 new mode 100755 index 396b2eae5..522d613f9 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp @@ -52,7 +52,7 @@ Status SingleKvStoreProxy::Put(const Key &key, const Value &value) } int error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed with error code %d", error); + ZLOGW("SendRequest failed with error code=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -75,7 +75,7 @@ Status SingleKvStoreProxy::Put(const Key &key, const Value &value) // rawdata: keySize | key | ValueSize | value int32_t error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -96,7 +96,7 @@ Status SingleKvStoreProxy::Delete(const Key &key) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -120,12 +120,12 @@ Status SingleKvStoreProxy::Get(const Key &key, Value &value) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } @@ -165,6 +165,7 @@ Status SingleKvStoreProxy::SubscribeKvStore(const SubscribeType subscribeType, return Status::IPC_ERROR; } if (observer == nullptr) { + ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } if (!data.WriteInt32(static_cast(subscribeType)) || @@ -175,7 +176,7 @@ Status SingleKvStoreProxy::SubscribeKvStore(const SubscribeType subscribeType, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -191,6 +192,7 @@ Status SingleKvStoreProxy::UnSubscribeKvStore(const SubscribeType subscribeType, return Status::IPC_ERROR; } if (observer == nullptr) { + ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } if (!data.WriteInt32(static_cast(subscribeType)) || @@ -202,7 +204,7 @@ Status SingleKvStoreProxy::UnSubscribeKvStore(const SubscribeType subscribeType, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -223,12 +225,13 @@ Status SingleKvStoreProxy::GetEntries(const Key &prefixKey, std::vector & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETENTRIES, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -249,7 +252,7 @@ Status SingleKvStoreProxy::GetEntries(const Key &prefixKey, std::vector & // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, bufferSize); return Status::IPC_ERROR; } @@ -289,12 +292,13 @@ Status SingleKvStoreProxy::GetEntriesWithQuery(const std::string &query, std::ve MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETENTRIESWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -315,7 +319,7 @@ Status SingleKvStoreProxy::GetEntriesWithQuery(const std::string &query, std::ve // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, bufferSize); return Status::IPC_ERROR; } @@ -352,17 +356,19 @@ void SingleKvStoreProxy::GetResultSet(const Key &prefixKey, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETRESULTSET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); callback(Status::IPC_ERROR, nullptr); return; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); callback(status, nullptr); return; } sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject reply failed"); callback(status, nullptr); return; } @@ -388,17 +394,19 @@ void SingleKvStoreProxy::GetResultSetWithQuery(const std::string &query, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETRESULTSETWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); callback(Status::IPC_ERROR, nullptr); return; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); callback(status, nullptr); return; } sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject reply failed"); callback(status, nullptr); return; } @@ -423,12 +431,13 @@ Status SingleKvStoreProxy::GetCountWithQuery(const std::string &query, int &resu MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETCOUNTWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -445,6 +454,7 @@ Status SingleKvStoreProxy::CloseResultSet(sptr resultSetPtr) return Status::IPC_ERROR; } if (resultSetPtr == nullptr) { + ZLOGW("resultSetPtr is nullptr"); return Status::INVALID_ARGUMENT; } @@ -455,7 +465,7 @@ Status SingleKvStoreProxy::CloseResultSet(sptr resultSetPtr) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSERESULTSET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -486,7 +496,7 @@ Status SingleKvStoreProxy::Sync(const std::vector &deviceIds, SyncM } int32_t error = Remote()->SendRequest(SYNC, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -517,7 +527,7 @@ Status SingleKvStoreProxy::Sync(const std::vector &deviceIds, SyncM MessageParcel reply; int32_t error = Remote()->SendRequest(SYNC_WITH_CONDITION, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %d", error); + ZLOGE("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -539,7 +549,7 @@ Status SingleKvStoreProxy::RemoveDeviceData(const std::string &device) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REMOVEDEVICEDATA, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -565,7 +575,7 @@ Status SingleKvStoreProxy::RegisterSyncCallback(sptr callb MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REGISTERSYNCCALLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -582,7 +592,7 @@ Status SingleKvStoreProxy::UnRegisterSyncCallback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNREGISTERSYNCCALLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -608,6 +618,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) int64_t bufferSize = 0; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { + ZLOGW("entry length is too long, entry.key=%d, entry.value=%d", item.key.Size(), item.value.Size()); return Status::INVALID_ARGUMENT; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -625,6 +636,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) } MessageOption mo { MessageOption::TF_SYNC }; if (Remote()->SendRequest(PUTBATCH, data, reply, mo) != 0) { + ZLOGW("Remote() SendRequest failed."); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -655,7 +667,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUTBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -689,7 +701,7 @@ Status SingleKvStoreProxy::DeleteBatch(const std::vector &keys) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -705,7 +717,7 @@ Status SingleKvStoreProxy::StartTransaction() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTTRANSACTION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -721,7 +733,7 @@ Status SingleKvStoreProxy::Commit() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(COMMIT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -737,7 +749,7 @@ Status SingleKvStoreProxy::Rollback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(ROLLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -766,12 +778,12 @@ Status SingleKvStoreProxy::Control(KvControlCmd cmd, const KvParam &inputParam, MessageOption mo{MessageOption::TF_SYNC}; int32_t error = Remote()->SendRequest(CONTROL, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } @@ -882,7 +894,7 @@ Status SingleKvStoreProxy::Subscribe(const std::vector &deviceIds, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %d", error); + ZLOGE("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -912,7 +924,7 @@ Status SingleKvStoreProxy::UnSubscribe(const std::vector &deviceIds MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %d", error); + ZLOGE("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -967,6 +979,7 @@ int SingleKvStoreStub::PutOnRemote(MessageParcel &data, MessageParcel &reply) } Status status = Put(key, value); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -983,6 +996,7 @@ int SingleKvStoreStub::DeleteOnRemote(MessageParcel &data, MessageParcel &reply) } Status status = Delete(*key); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -1043,6 +1057,7 @@ int SingleKvStoreStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessageParc SubscribeType subscribeType = static_cast(data.ReadInt32()); sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject reply failed"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { return -1; } @@ -1052,6 +1067,7 @@ int SingleKvStoreStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessageParc Status status = SubscribeKvStore(subscribeType, std::move(kvStoreObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -1070,6 +1086,7 @@ int SingleKvStoreStub::UnSubscribeKvStoreOnRemote(MessageParcel &data, MessagePa sptr kvStoreObserverProxy = iface_cast(remote); Status status = UnSubscribeKvStore(subscribeType, std::move(kvStoreObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -1118,6 +1135,7 @@ int SingleKvStoreStub::GetEntriesOnRemote(MessageParcel &data, MessageParcel &re std::vector entries; Status status = GetEntries(*keyPrefix, entries); if (status != Status::SUCCESS) { + ZLOGW("write status error"); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1130,7 +1148,7 @@ int SingleKvStoreStub::GetEntriesOnRemote(MessageParcel &data, MessageParcel &re } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -1176,6 +1194,7 @@ int SingleKvStoreStub::GetEntriesWithQueryOnRemote(MessageParcel &data, MessageP std::vector entries; Status status = GetEntriesWithQuery(query, entries); if (status != Status::SUCCESS) { + ZLOGW("write status error"); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1188,7 +1207,7 @@ int SingleKvStoreStub::GetEntriesWithQueryOnRemote(MessageParcel &data, MessageP } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -1229,7 +1248,7 @@ int SingleKvStoreStub::SyncOnRemote(MessageParcel &data, MessageParcel &reply) { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGW("SYNC list:%zu", devices.size()); + ZLOGW("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write sync status fail"); return -1; @@ -1313,7 +1332,7 @@ int SingleKvStoreStub::PutBatchOnRemote(MessageParcel &data, MessageParcel &repl } int len = data.ReadInt32(); if (len < 0) { - ZLOGW("invalid status. len %d", len); + ZLOGW("invalid status. len=%d", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write to parcel failed."); return -1; @@ -1380,7 +1399,7 @@ int SingleKvStoreStub::DeleteBatchOnRemote(MessageParcel &data, MessageParcel &r { int len = data.ReadInt32(); if (len < 0) { - ZLOGW("len %d invalid after ipc", len); + ZLOGW("len=%d invalid after ipc", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write delete failed."); return -1; @@ -1447,7 +1466,7 @@ int SingleKvStoreStub::OnSecurityLevelRequest(MessageParcel &data, MessageParcel SecurityLevel securityLevel = SecurityLevel::NO_LABEL; auto status = GetSecurityLevel(securityLevel); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("Get SecurityLevel ipc failed."); + ZLOGW("Get SecurityLevel ipc error."); return -1; } if (!reply.WriteInt32(static_cast(securityLevel))) { @@ -1485,6 +1504,7 @@ int SingleKvStoreStub::GetCountWithQueryOnRemote(MessageParcel &data, MessagePar int result; Status status = GetCountWithQuery(query, result); if (status != Status::SUCCESS) { + ZLOGW("get status failed."); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1501,6 +1521,7 @@ int SingleKvStoreStub::CloseResultSetOnRemote(MessageParcel &data, MessageParcel { sptr obj = data.ReadRemoteObject(); if (obj == nullptr) { + ZLOGW("ReadRemoteObject failed."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { return -1; } @@ -1509,6 +1530,7 @@ int SingleKvStoreStub::CloseResultSetOnRemote(MessageParcel &data, MessageParcel sptr kvStoreResultSetProxy = iface_cast(obj); Status status = CloseResultSet(kvStoreResultSetProxy); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -1605,7 +1627,7 @@ int SingleKvStoreStub::OnSyncRequest(MessageParcel &data, MessageParcel &reply) { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGI("SYNC list:%zu", devices.size()); + ZLOGI("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; @@ -1645,7 +1667,7 @@ int SingleKvStoreStub::OnSubscribeRequest(MessageParcel &data, MessageParcel &re { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGE("SYNC list:%zu", devices.size()); + ZLOGE("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; @@ -1666,7 +1688,7 @@ int SingleKvStoreStub::OnUnSubscribeRequest(MessageParcel &data, MessageParcel & { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGE("SYNC list:%zu", devices.size()); + ZLOGE("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp old mode 100644 new mode 100755 index 9674351eb..93f25b730 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp @@ -72,7 +72,7 @@ void KvStoreSnapshotImplProxy::GetEntries(const Key &prefixKey, const Key &nextK Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success, which is %d", static_cast(status)); + ZLOGW("status not success, which = %d", static_cast(status)); callback(status, entries, Key()); return; } @@ -94,7 +94,7 @@ void KvStoreSnapshotImplProxy::GetEntries(const Key &prefixKey, const Key &nextK // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, bufferSize); callback(Status::IPC_ERROR, entries, Key()); return; @@ -128,14 +128,17 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, } std::vector keyList; if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGW("SetMaxCapacity failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } if (!data.WriteParcelable(&prefixKey)) { + ZLOGW("prefixKey WriteParcelable failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } if (!data.WriteParcelable(&nextKey)) { + ZLOGW("nextKey WriteParcelable failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } @@ -149,7 +152,7 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success, which is %d", static_cast(status)); + ZLOGW("status not successful, error = %d", static_cast(status)); callback(status, keyList, Key()); return; } @@ -171,7 +174,7 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyKeyCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyKeyCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyKeyCount, bufferSize); + ZLOGW("replyKeyCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyKeyCount, bufferSize); callback(Status::IPC_ERROR, keyList, Key()); return; } @@ -201,9 +204,11 @@ Status KvStoreSnapshotImplProxy::Get(const Key &key, Value &value) return Status::IPC_ERROR; } if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGW("SetMaxCapacity failed"); return Status::IPC_ERROR; } if (!data.WriteParcelable(&key)) { + ZLOGW("key WriteParcelable failed"); return Status::IPC_ERROR; } @@ -211,12 +216,12 @@ Status KvStoreSnapshotImplProxy::Get(const Key &key, Value &value) ZLOGI("start"); int32_t error = Remote()->SendRequest(GET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } @@ -334,7 +339,7 @@ int32_t KvStoreSnapshotImplStub::GetEntriesOnRemote(MessageParcel &data, Message } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -382,6 +387,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce if (keyPrefix == nullptr) { ZLOGW("keyPrefix is null"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("keyPrefix WriteInt32 error"); return -1; } if (!reply.WriteParcelable(nullptr)) { @@ -392,6 +398,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce if (nextKey == nullptr) { ZLOGW("nextKey is null. return."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("nextKey WriteInt32 error"); return -1; } if (!reply.WriteParcelable(nullptr)) { @@ -413,7 +420,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce } ZLOGI("getting large key set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR)) || !reply.WriteParcelable(&nxtKey)) { ZLOGW("write status failed."); @@ -460,6 +467,7 @@ int32_t KvStoreSnapshotImplStub::GetRemote(MessageParcel &data, MessageParcel &r if (key == nullptr) { ZLOGW("key is null"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("key WriteInt32 is null"); return -1; } if (!reply.WriteInt32(0)) { @@ -519,6 +527,7 @@ int32_t KvStoreSnapshotImplStub::OnRemoteRequest(uint32_t code, MessageParcel &d return -1; } if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGW("reply SetMaxCapacity failed."); return -1; } switch (code) { @@ -533,6 +542,7 @@ int32_t KvStoreSnapshotImplStub::OnRemoteRequest(uint32_t code, MessageParcel &d } default: if (!reply.WriteInt32((int32_t)Status::ERROR)) { + ZLOGW("reply WriteInt32 status failed."); return -1; } return 0; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp index 863547b13..bcde27f73 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp @@ -60,7 +60,7 @@ void KvStoreSyncCallbackProxy::SyncCompleted(const std::map MessageOption mo { MessageOption::TF_SYNC }; int error = Remote()->SendRequest(SYNCCOMPLETED, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error %d", error); + ZLOGW("SendRequest failed, error=%d", error); } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp index 2f084d300..d0227968a 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp @@ -57,6 +57,7 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, std::vector &output) bool ITypesUtil::Marshalling(const Entry &entry, MessageParcel &data) { if (!Marshalling(entry.key, data)) { + ZLOGW("Marshalling failed"); return false; } return Marshalling(entry.value, data); @@ -65,6 +66,7 @@ bool ITypesUtil::Marshalling(const Entry &entry, MessageParcel &data) bool ITypesUtil::Unmarshalling(MessageParcel &data, Entry &output) { if (!Unmarshalling(data, output.key)) { + ZLOGW("Unmarshalling failed"); return false; } return Unmarshalling(data, output.value); @@ -73,9 +75,11 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, Entry &output) bool ITypesUtil::Marshalling(const DeviceInfo &entry, MessageParcel &data) { if (!data.WriteString(entry.deviceId)) { + ZLOGW("write deviceId failed"); return false; } if (!data.WriteString(entry.deviceName)) { + ZLOGW("write deviceName failed"); return false; } return data.WriteString(entry.deviceType); @@ -84,9 +88,11 @@ bool ITypesUtil::Marshalling(const DeviceInfo &entry, MessageParcel &data) bool ITypesUtil::Unmarshalling(MessageParcel &data, DeviceInfo &output) { if (!data.ReadString(output.deviceId)) { + ZLOGW("read deviceId failed"); return false; } if (!data.ReadString(output.deviceName)) { + ZLOGW("read deviceName failed"); return false; } return data.ReadString(output.deviceType); @@ -104,14 +110,17 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, std::vector &out bool ITypesUtil::Marshalling(const ChangeNotification ¬ification, MessageParcel &parcel) { if (!Marshalling(notification.GetInsertEntries(), parcel)) { + ZLOGW("GetInsertEntries failed"); return false; } if (!Marshalling(notification.GetUpdateEntries(), parcel)) { + ZLOGW("GetUpdateEntries failed"); return false; } if (!Marshalling(notification.GetDeleteEntries(), parcel)) { + ZLOGW("GetDeleteEntries failed"); return false; } if (!parcel.WriteString(notification.GetDeviceId())) { @@ -126,14 +135,17 @@ bool ITypesUtil::Unmarshalling(MessageParcel &parcel, ChangeNotification &output { std::vector insertEntries; if (!Unmarshalling(parcel, insertEntries)) { + ZLOGW("insertEntries failed"); return false; } std::vector updateEntries; if (!Unmarshalling(parcel, updateEntries)) { + ZLOGW("updateEntries failed"); return false; } std::vector deleteEntries; if (!Unmarshalling(parcel, deleteEntries)) { + ZLOGW("deleteEntries failed"); return false; } std::string deviceId; @@ -368,6 +380,7 @@ int64_t ITypesUtil::GetTotalSize(const std::vector &entries) int64_t bufferSize = 1; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { + ZLOGW("entry length too long key=%d, value=%d", item.key.Size(), item.value.Size()); return -bufferSize; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -379,6 +392,7 @@ int64_t ITypesUtil::GetTotalSize(const std::vector &entries) int64_t bufferSize = 1; for (const auto &item : entries) { if (item.Size() > Constant::MAX_KEY_LENGTH) { + ZLOGW("entry length too long, size=%d", item.Size()); return -bufferSize; } bufferSize += item.RawSize(); @@ -391,21 +405,25 @@ bool ITypesUtil::ReadVector(Parcel &parcel, std::vector &val, bool (Parcel::* { int32_t len = parcel.ReadInt32(); if (len < 0) { + ZLOGW("read parcel error len=%d", len); return false; } size_t readAbleSize = parcel.GetReadableBytes(); size_t size = static_cast(len); if ((size > readAbleSize) || (size > val.max_size())) { + ZLOGW("parcel size too long, size=%d", size); return false; } val.resize(size); if (val.size() < size) { + ZLOGW("size too long, size=%d", size); return false; } for (auto &v : val) { if (!(parcel.*read)(v)) { + ZLOGW("parcel read value error"); return false; } } @@ -417,15 +435,18 @@ template bool ITypesUtil::WriteVector(Parcel &parcel, const std::vector &val, bool (Parcel::*writer)(const T &)) { if (val.size() > INT_MAX) { + ZLOGW("value size too long, size=%d", val.size()); return false; } if (!parcel.WriteInt32(static_cast(val.size()))) { + ZLOGW("parcel write size error"); return false; } for (auto &v : val) { if (!(parcel.*writer)(v)) { + ZLOGW("parcel write value error"); return false; } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp old mode 100644 new mode 100755 index 00192e53c..3840e8cbe --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp @@ -63,7 +63,7 @@ Status KvStoreClient::GetKvStoreSnapshot(std::shared_ptr observ }; kvStoreProxy_->GetKvStoreSnapshot(kvStoreObserverClient, snapshotCallbackFunction); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error: %d.", static_cast(statusTmp)); + ZLOGE("return error=%d.", static_cast(statusTmp)); return statusTmp; } @@ -95,13 +95,13 @@ Status KvStoreClient::ReleaseKvStoreSnapshot(std::shared_ptr &s sptr snapshotProxyTmp = kvStoreSnapshotClient->GetkvStoreSnapshotProxy(); Status status = kvStoreProxy_->ReleaseKvStoreSnapshot(std::move(snapshotProxyTmp)); snapshot = nullptr; - ZLOGI("return: %d.", static_cast(status)); + ZLOGI("return=%d.", static_cast(status)); return status; } Status KvStoreClient::Put(const Key &key, const Value &value) { - ZLOGD("key: %zu value: %zu.", key.Size(), value.Size()); + ZLOGD("key=%zu value=%zu.", key.Size(), value.Size()); DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); std::vector keyData = Constant::TrimCopy>(key.Data()); @@ -120,7 +120,7 @@ Status KvStoreClient::Put(const Key &key, const Value &value) Status KvStoreClient::PutBatch(const std::vector &entries) { - ZLOGI("entry size: %zu", entries.size()); + ZLOGI("entry size=%zu", entries.size()); DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); if (entries.size() > Constant::MAX_BATCH_SIZE) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client_death_observer.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client_death_observer.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_observer_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_observer_client.cpp old mode 100644 new mode 100755 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp old mode 100644 new mode 100755 index 61c4707aa..25a7a3a69 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp @@ -17,11 +17,14 @@ #include "kvstore_resultset_client.h" #include "dds_trace.h" +#include "log_print.h" namespace OHOS::DistributedKv { KvStoreResultSetClient::KvStoreResultSetClient(sptr kvStoreProxy) :kvStoreResultSetProxy_(kvStoreProxy) -{} +{ + ZLOGI("constructor"); +} int KvStoreResultSetClient::GetCount() const { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp old mode 100644 new mode 100755 index c0f239c76..4a51ee120 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp @@ -80,6 +80,7 @@ sptr KvStoreServiceDeathNotifier::GetDistributedKvDataServi void KvStoreServiceDeathNotifier::RegisterClientDeathObserver() { if (kvDataServiceProxy_ == nullptr) { + ZLOGE("initialize proxy failed."); return; } if (clientDeathObserverPtr_ == nullptr) { @@ -97,9 +98,9 @@ void KvStoreServiceDeathNotifier::AddServiceDeathWatcher(std::shared_ptr lg(watchMutex_); auto ret = serviceDeathWatchers_.insert(watcher); if (ret.second) { - ZLOGI("success set size: %zu", serviceDeathWatchers_.size()); + ZLOGI("success set size=%zu", serviceDeathWatchers_.size()); } else { - ZLOGE("failed set size: %zu", serviceDeathWatchers_.size()); + ZLOGE("failed set size=%zu", serviceDeathWatchers_.size()); } } @@ -109,9 +110,9 @@ void KvStoreServiceDeathNotifier::RemoveServiceDeathWatcher(std::shared_ptr lg(watchMutex_); kvDataServiceProxy_ = nullptr; - ZLOGI("watcher set size: %zu", serviceDeathWatchers_.size()); + ZLOGI("watcher set size=%zu", serviceDeathWatchers_.size()); for (const auto &watcher : serviceDeathWatchers_) { std::thread th = std::thread([watcher]() { watcher->OnRemoteDied(); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp index b20d66156..ce9b7448b 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp @@ -84,6 +84,7 @@ Status KvStoreSnapshotClient::GetEntries(const Key &prefixKey, std::vector &en [&status, &entries, &startKey](Status stat, auto &result, Key next) { status = stat; if (stat != Status::SUCCESS) { + ZLOGE("status error=%d.", status); return; } startKey = result.empty() ? "" : next; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp old mode 100644 new mode 100755 index 028362ba5..13a74fcef --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp @@ -41,7 +41,7 @@ void KvStoreSyncCallbackClient::AddSyncCallback(const std::shared_ptr kvStoreProxy, const std::string &storeId) : kvStoreProxy_(kvStoreProxy), storeId_(storeId), syncCallbackClient_(new KvStoreSyncCallbackClient()), syncObserver_(std::make_shared()) -{} +{ + ZLOGI("constructor."); +} SingleKvStoreClient::~SingleKvStoreClient() { + ZLOGI("destructor."); kvStoreProxy_->UnRegisterSyncCallback(); syncObserver_->Clean(); } @@ -88,7 +91,7 @@ Status SingleKvStoreClient::GetResultSet(const Key &prefixKey, std::shared_ptrGetResultSet(prefixKey, callFun); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error: %d.", static_cast(statusTmp)); + ZLOGE("return error=%d.", static_cast(statusTmp)); return statusTmp; } @@ -120,7 +123,7 @@ Status SingleKvStoreClient::GetResultSetWithQuery(const std::string &query, }; kvStoreProxy_->GetResultSetWithQuery(query, callFun); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error: %d.", static_cast(statusTmp)); + ZLOGE("return error=%d.", static_cast(statusTmp)); return statusTmp; } @@ -226,7 +229,7 @@ Status SingleKvStoreClient::Put(const Key &key, const Value &value) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); - ZLOGI("key: %zu value: %zu.", key.Size(), value.Size()); + ZLOGI("key=%zu value=%zu.", key.Size(), value.Size()); std::vector keyData = Constant::TrimCopy>(key.Data()); if (keyData.size() == 0 || keyData.size() > Constant::MAX_KEY_LENGTH || value.Size() > Constant::MAX_VALUE_LENGTH) { @@ -348,7 +351,7 @@ Status SingleKvStoreClient::PutBatch(const std::vector &entries) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); - ZLOGI("entry size: %zu", entries.size()); + ZLOGI("entry size=%zu", entries.size()); if (entries.size() > Constant::MAX_BATCH_SIZE) { ZLOGE("batch size must less than 128."); return Status::INVALID_ARGUMENT; @@ -422,12 +425,14 @@ Status SingleKvStoreClient::GetSyncParam(KvSyncParam &syncParam) KvParam output; Status ret = Control(KvControlCmd::GET_SYNC_PARAM, inputEmpty, output); if (ret != Status::SUCCESS) { + ZLOGE("ret error=%d.", ret); return ret; } if (output.Size() == sizeof(uint32_t)) { syncParam.allowedDelayMs = TransferByteArrayToType(output.Data()); return Status::SUCCESS; } + ZLOGE("output size error."); return Status::ERROR; } diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp index 1be079979..a1a9c76cf 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp @@ -43,7 +43,7 @@ static sptr GetDistributedDataManager() std::this_thread::sleep_for(std::chrono::seconds(RdbManagerImpl::RETRY_INTERVAL)); continue; } - ZLOGI("get distributed data manager success"); + ZLOGI("get distributed data manager successful"); return iface_cast(remoteObject); } @@ -59,7 +59,7 @@ static void LinkToDeath(const sptr& remote) if (!remote->AddDeathRecipient(deathRecipient)) { ZLOGE("add death recipient failed"); } - ZLOGE("success"); + ZLOGE("successful"); } RdbManagerImpl::RdbManagerImpl() @@ -104,6 +104,7 @@ std::shared_ptr RdbManagerImpl::GetRdbService(const RdbSyncerParam& } auto service = GetRdbService(); if (service == nullptr) { + ZLOGE("get rdb service is nullptr"); return nullptr; } if (((RdbServiceProxy *)service.GetRefPtr())->InitNotifier(param) != RDB_OK) { @@ -128,10 +129,12 @@ void RdbManagerImpl::OnRemoteDied() param.bundleName_ = bundleName_; auto service = GetRdbService(param); if (service == nullptr) { + ZLOGI("rdb service alreadly dead"); return; } proxy = std::static_pointer_cast(service); if (proxy == nullptr) { + ZLOGI("rdb service proxy alreadly dead"); return; } ZLOGI("restore observer"); diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp index dba5a48a5..072ac16e4 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp @@ -44,6 +44,7 @@ int32_t RdbNotifierProxy::OnComplete(uint32_t seqNum, const SyncResult &result) return RDB_ERROR; } if (!DistributedKv::ITypesUtil::Marshalling(result, data)) { + ZLOGE("marshalling result and data failed"); return RDB_ERROR; } @@ -109,6 +110,7 @@ int RdbNotifierStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message { ZLOGI("code=%{public}u", code); if (!CheckInterfaceToken(data)) { + ZLOGE("CheckInterfaceToken data error."); return RDB_ERROR; } diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp index 899882932..009be07fd 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp @@ -36,7 +36,7 @@ void RdbServiceProxy::OnSyncComplete(uint32_t seqNum, const SyncResult &result) void RdbServiceProxy::OnDataChange(const std::string& storeName, const std::vector &devices) { - ZLOGI("%{public}s", storeName.c_str()); + ZLOGI("storeName=%{public}s", storeName.c_str()); observers_.ComputeIfPresent( storeName, [&devices] (const auto& key, const ObserverMapValue& value) { for (const auto& observer : value.first) { @@ -90,7 +90,7 @@ int32_t RdbServiceProxy::InitNotifier(const RdbSyncerParam& param) return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); return RDB_OK; } @@ -165,10 +165,10 @@ int32_t RdbServiceProxy::DoSync(const RdbSyncerParam& param, const SyncOption &o { SyncResult result; if (DoSync(param, option, predicates, result) != RDB_OK) { - ZLOGI("failed"); + ZLOGE("dosync failed"); return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); if (callback != nullptr) { callback(result); @@ -222,12 +222,12 @@ int32_t RdbServiceProxy::DoAsync(const RdbSyncerParam& param, const SyncOption & ZLOGI("num=%{public}u", num); if (DoAsync(param, num, option, predicates) != RDB_OK) { - ZLOGE("failed"); + ZLOGE("do async failed"); syncCallbacks_.Erase(num); return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); return RDB_OK; } @@ -262,6 +262,7 @@ int32_t RdbServiceProxy::Sync(const RdbSyncerParam& param, const SyncOption &opt const RdbPredicates &predicates, const SyncCallback &callback) { if (option.isBlock) { + ZLOGI("option isBlock"); return DoSync(param, option, predicates, callback); } return DoAsync(param, option, predicates, callback); @@ -275,7 +276,7 @@ int32_t RdbServiceProxy::Subscribe(const RdbSyncerParam ¶m, const SubscribeO return RDB_ERROR; } if (DoSubscribe(param) != RDB_OK) { - ZLOGI("communicate to server failed"); + ZLOGE("communicate to server failed"); return RDB_ERROR; } observers_.Compute( diff --git a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp index d3f105d41..8d922e98c 100644 --- a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp @@ -29,19 +29,19 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("createKVManager", JsKVManager::CreateKVManager) }; napi_status status = napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - ZLOGI("init createKVManager %{public}d", status); + ZLOGI("init createKVManager status=%{public}d", status); status = napi_set_named_property(env, exports, "FieldNode", JsFieldNode::Constructor(env)); - ZLOGI("init FieldNode %{public}d", status); + ZLOGI("init FieldNode status=%{public}d", status); status = napi_set_named_property(env, exports, "Schema", JsSchema::Constructor(env)); - ZLOGI("init Schema %{public}d", status); + ZLOGI("init Schema status=%{public}d", status); status = napi_set_named_property(env, exports, "Query", JsQuery::Constructor(env)); - ZLOGI("init Query %{public}d", status); + ZLOGI("init Query status=%{public}d", status); status = InitConstProperties(env, exports); - ZLOGI("init Enumerate Constants %{public}d", status); + ZLOGI("init Enumerate Constants status=%{public}d", status); return exports; } diff --git a/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp index 7034d5883..ae7f74928 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp @@ -38,10 +38,12 @@ static std::string GetDeviceKey(const std::string& deviceId, const std::string& JsDeviceKVStore::JsDeviceKVStore(const std::string& storeId) : JsKVStore(storeId) { + ZLOGD("constructor"); } napi_value JsDeviceKVStore::Constructor(napi_env env) { + ZLOGD("JsDeviceKVStore::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("put", JsKVStore::Put), DECLARE_NAPI_FUNCTION("delete", JsKVStore::Delete), @@ -100,7 +102,7 @@ napi_value JsDeviceKVStore::Get(napi_env env, napi_callback_info info) OHOS::DistributedKv::Value value; auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Get(deviceKey, value); - ZLOGD("kvStore->Get return %{public}d", status); + ZLOGD("kvStore->Get return status=%{public}d", status); ctxt->value = JSUtil::Blob2VariantValue(value); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Get() failed!"); @@ -192,16 +194,16 @@ napi_value JsDeviceKVStore::GetEntries(napi_env env, napi_callback_info info) std::string deviceKey = GetDeviceKey(ctxt->va.deviceId, ctxt->va.keyPrefix); OHOS::DistributedKv::Key keyPrefix(deviceKey); status = kvStore->GetEntries(keyPrefix, ctxt->entries); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::DEVICEID_QUERY) { auto query = ctxt->va.query->GetNative(); query.DeviceId(ctxt->va.deviceId); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetEntries() failed!"); @@ -250,16 +252,16 @@ napi_value JsDeviceKVStore::GetResultSet(napi_env env, napi_callback_info info) std::string deviceKey = GetDeviceKey(ctxt->va.deviceId, ctxt->va.keyPrefix); OHOS::DistributedKv::Key keyPrefix(deviceKey); status = kvStore->GetResultSet(keyPrefix, kvResultSet); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::DEVICEID_QUERY) { auto query = ctxt->va.query->GetNative(); query.DeviceId(ctxt->va.deviceId); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetResultSet() failed!"); @@ -300,7 +302,7 @@ napi_value JsDeviceKVStore::CloseResultSet(napi_env env, napi_callback_info info auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->CloseResultSet(ctxt->resultSet->GetNative()); - ZLOGD("kvStore->CloseResultSet return %{public}d", status); + ZLOGD("kvStore->CloseResultSet return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->CloseResultSet failed!"); }; @@ -338,7 +340,7 @@ napi_value JsDeviceKVStore::GetResultSize(napi_env env, napi_callback_info info) query.DeviceId(ctxt->va.deviceId); } Status status = kvStore->GetCountWithQuery(query.ToString(), ctxt->resultSize); - ZLOGD("kvStore->GetCountWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetCountWithQuery() return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetCountWithQuery() failed!"); }; @@ -372,7 +374,7 @@ napi_value JsDeviceKVStore::RemoveDeviceData(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->RemoveDeviceData(ctxt->deviceId); - ZLOGD("kvStore->RemoveDeviceData return %{public}d", status); + ZLOGD("kvStore->RemoveDeviceData return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->RemoveDeviceData() failed!"); }; @@ -385,6 +387,7 @@ napi_value JsDeviceKVStore::RemoveDeviceData(napi_env env, napi_callback_info in */ napi_value JsDeviceKVStore::Sync(napi_env env, napi_callback_info info) { + ZLOGD("JsDeviceKVStore::Sync"); struct SyncContext : public ContextBase { std::vector deviceIdList; uint32_t mode = 0; @@ -404,7 +407,7 @@ napi_value JsDeviceKVStore::Sync(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Sync(ctxt->deviceIdList, static_cast(ctxt->mode)); - ZLOGD("kvStore->Sync return %{public}d!", status); + ZLOGD("kvStore->Sync return status=%{public}d!", status); NAPI_ASSERT(env, status == Status::SUCCESS, "kvStore->Sync() failed!"); return nullptr; } diff --git a/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp b/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp index c18072280..d44e90c37 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp @@ -41,6 +41,7 @@ std::map JsFieldNode::valueTypeToString_ = { JsFieldNode::JsFieldNode(const std::string& fName) : fieldName(fName) { + ZLOGD("constructor"); } std::string JsFieldNode::GetFieldName() @@ -63,6 +64,7 @@ JsFieldNode::json JsFieldNode::GetValueForJson() napi_value JsFieldNode::Constructor(napi_env env) { + ZLOGD("JsFieldNode::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("appendChild", JsFieldNode::AppendChild), DECLARE_NAPI_GETTER_SETTER("default", JsFieldNode::GetDefaultValue, JsFieldNode::SetDefaultValue), @@ -251,6 +253,7 @@ std::string JsFieldNode::ValueTypeToString(uint32_t type) // DistributedDB::FieldType auto it = valueTypeToString_.find(type); if (valueTypeToString_.find(type) != valueTypeToString_.end()) { + ZLOGD("find type is the last"); return it->second; } else { return std::string(); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp index 8759ac81d..2966ee05c 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp @@ -126,7 +126,7 @@ napi_value JsKVManager::GetKVStore(napi_env env, napi_callback_info info) StoreId storeId = { ctxt->storeId }; std::shared_ptr kvStore; Status status = kvm->kvDataManager_.GetSingleKvStore(ctxt->options, appId, storeId, kvStore); - ZLOGD("GetSingleKvStore return status:%{public}d", status); + ZLOGD("GetSingleKvStore return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "KVManager->GetSingleKvStore() failed!"); ctxt->kvStore->SetNative(kvStore); @@ -172,7 +172,7 @@ napi_value JsKVManager::CloseKVStore(napi_env env, napi_callback_info info) AppId appId { ctxt->appId }; StoreId storeId { ctxt->storeId }; Status status = reinterpret_cast(ctxt->native)->kvDataManager_.CloseKvStore(appId, storeId); - ZLOGD("CloseKVStore return status:%{public}d", status); + ZLOGD("CloseKVStore return status=%{public}d", status); ctxt->status = ((status == Status::SUCCESS) || (status == Status::STORE_NOT_FOUND) || (status == Status::STORE_NOT_OPEN)) ? napi_ok @@ -209,7 +209,7 @@ napi_value JsKVManager::DeleteKVStore(napi_env env, napi_callback_info info) AppId appId { ctxt->appId }; StoreId storeId { ctxt->storeId }; Status status = reinterpret_cast(ctxt->native)->kvDataManager_.DeleteKvStore(appId, storeId); - ZLOGD("DeleteKvStore status:%{public}d", status); + ZLOGD("DeleteKvStore status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; }; return NapiQueue::AsyncWork(env, ctxt, std::string(__FUNCTION__), execute); @@ -242,25 +242,26 @@ napi_value JsKVManager::GetAllKVStoreId(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, kvm != nullptr, "KVManager is null, failed!"); AppId appId { ctxt->appId }; Status status = kvm->kvDataManager_.GetAllKvStoreId(appId, ctxt->storeIdList); - ZLOGD("execute status:%{public}d", status); + ZLOGD("execute status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; }; auto output = [env, ctxt](napi_value& result) { ctxt->status = JSUtil::SetValue(env, ctxt->storeIdList, result); - ZLOGD("output status:%{public}d", ctxt->status); + ZLOGD("output status=%{public}d", ctxt->status); }; return NapiQueue::AsyncWork(env, ctxt, std::string(__FUNCTION__), execute, output); } napi_value JsKVManager::On(napi_env env, napi_callback_info info) { + ZLOGD("KVManager::On()"); auto ctxt = std::make_shared(); auto input = [env, ctxt](size_t argc, napi_value* argv) { // required 2 arguments :: CHECK_ARGS_RETURN_VOID(ctxt, argc == 2, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("subscribe to event:%{public}s", event.c_str()); + ZLOGI("subscribe to event=%{public}s", event.c_str()); CHECK_ARGS_RETURN_VOID(ctxt, event == "distributedDataServiceDie", "invalid arg[0], i.e. invalid event!"); napi_valuetype valueType = napi_undefined; @@ -298,7 +299,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); // required 1 arguments :: - ZLOGI("unsubscribe to event:%{public}s %{public}s specified", event.c_str(), (argc == 1) ? "without": "with"); + ZLOGI("unsubscribe to event=%{public}s %{public}s specified", event.c_str(), (argc == 1) ? "without": "with"); CHECK_ARGS_RETURN_VOID(ctxt, event == "distributedDataServiceDie", "invalid arg[0], i.e. invalid event!"); // have 2 arguments :: have the [callback] if (argc == 2) { @@ -320,7 +321,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) ++it; } } - ZLOGD("off mapsize: %{public}d", static_cast(proxy->deathRecipient_.size())); + ZLOGD("off mapsize=%{public}d", static_cast(proxy->deathRecipient_.size())); }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -330,6 +331,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) napi_value JsKVManager::Constructor(napi_env env) { + ZLOGD("KVManager::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("getKVStore", JsKVManager::GetKVStore), DECLARE_NAPI_FUNCTION("closeKVStore", JsKVManager::CloseKVStore), @@ -344,6 +346,7 @@ napi_value JsKVManager::Constructor(napi_env env) napi_value JsKVManager::New(napi_env env, napi_callback_info info) { + ZLOGD("KVManager::New"); std::string bundleName; auto ctxt = std::make_shared(); auto input = [env, ctxt, &bundleName](size_t argc, napi_value* argv) { @@ -356,7 +359,7 @@ napi_value JsKVManager::New(napi_env env, napi_callback_info info) ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - JsKVManager* kvManager = new (std::nothrow) JsKVManager(bundleName, env); + JsKVManager* kvManager = new (std::nothrow) JsKVManager(bundleName); NAPI_ASSERT(env, kvManager !=nullptr, "no memory for kvManager"); auto finalize = [](napi_env env, void* data, void* hint) { diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp index b82ae3aa7..7af0213f8 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp @@ -182,7 +182,7 @@ napi_value JsKVStore::OnEvent(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, argc >= 2, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("subscribe to event:%{public}s", event.c_str()); + ZLOGI("subscribe to event=%{public}s", event.c_str()); auto handle = onEventHandlers_.find(event); CHECK_ARGS_RETURN_VOID(ctxt, handle != onEventHandlers_.end(), "invalid arg[0], i.e. unsupported event"); // shift 1 argument, for JsKVStore::Exec. @@ -208,7 +208,7 @@ napi_value JsKVStore::OffEvent(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, argc >= 1, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("unsubscribe to event:%{public}s", event.c_str()); + ZLOGI("unsubscribe to event=%{public}s", event.c_str()); auto handle = offEventHandlers_.find(event); CHECK_ARGS_RETURN_VOID(ctxt, handle != offEventHandlers_.end(), "invalid arg[0], i.e. unsupported event"); // shift 1 argument, for JsKVStore::Exec. @@ -228,6 +228,7 @@ napi_value JsKVStore::OffEvent(napi_env env, napi_callback_info info) */ napi_value JsKVStore::PutBatch(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct PutBatchContext : public ContextBase { std::vector entries; }; @@ -259,6 +260,7 @@ napi_value JsKVStore::PutBatch(napi_env env, napi_callback_info info) */ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct DeleteBatchContext : public ContextBase { std::vector keys; }; @@ -279,7 +281,7 @@ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) } auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->DeleteBatch(keys); - ZLOGD("kvStore->DeleteBatch return %{public}d", status); + ZLOGD("kvStore->DeleteBatch return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->DeleteBatch failed!"); }; @@ -295,13 +297,14 @@ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) */ napi_value JsKVStore::StartTransaction(napi_env env, napi_callback_info info) { + ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->StartTransaction(); - ZLOGD("kvStore->StartTransaction return %{public}d", status); + ZLOGD("kvStore->StartTransaction return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->StartTransaction() failed!"); }; @@ -317,13 +320,14 @@ napi_value JsKVStore::StartTransaction(napi_env env, napi_callback_info info) */ napi_value JsKVStore::Commit(napi_env env, napi_callback_info info) { + ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->Commit(); - ZLOGD("kvStore->Commit return %{public}d", status); + ZLOGD("kvStore->Commit return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Commit() failed!"); }; @@ -339,13 +343,14 @@ napi_value JsKVStore::Commit(napi_env env, napi_callback_info info) */ napi_value JsKVStore::Rollback(napi_env env, napi_callback_info info) { + ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->Rollback(); - ZLOGD("kvStore->Commit return %{public}d", status); + ZLOGD("kvStore->Commit return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Rollback() failed!"); }; @@ -361,6 +366,7 @@ napi_value JsKVStore::Rollback(napi_env env, napi_callback_info info) */ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct EnableSyncContext : public ContextBase { bool enable = false; }; @@ -376,7 +382,7 @@ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->SetCapabilityEnabled(ctxt->enable); - ZLOGD("kvStore->SetCapabilityEnabled return %{public}d", status); + ZLOGD("kvStore->SetCapabilityEnabled return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->SetCapabilityEnabled() failed!"); }; @@ -392,6 +398,7 @@ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) */ napi_value JsKVStore::SetSyncRange(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct SyncRangeContext : public ContextBase { std::vector localLabels; std::vector remoteSupportLabels; @@ -410,7 +417,7 @@ napi_value JsKVStore::SetSyncRange(napi_env env, napi_callback_info info) auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->SetCapabilityRange(ctxt->localLabels, ctxt->remoteSupportLabels); - ZLOGD("kvStore->SetCapabilityRange return %{public}d", status); + ZLOGD("kvStore->SetCapabilityRange return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->SetCapabilityRange() failed!"); }; @@ -437,7 +444,7 @@ void JsKVStore::OnDataChange(napi_env env, size_t argc, napi_value* argv, std::s CHECK_STATUS_RETURN_VOID(ctxt, "napi_typeof failed!"); CHECK_ARGS_RETURN_VOID(ctxt, valueType == napi_function, "invalid arg[2], i.e. invalid callback"); - ZLOGI("subscribe data change type %{public}d", type); + ZLOGI("subscribe data change type=%{public}d", type); auto proxy = reinterpret_cast(ctxt->native); std::lock_guard lck(proxy->listMutex_); for (auto& it : proxy->dataObserver_[type]) { @@ -558,6 +565,7 @@ void JsKVStore::OffSyncComplete(napi_env env, size_t argc, napi_value* argv, std */ napi_status JsKVStore::RegisterSyncCallback(std::shared_ptr callback) { + ZLOGD("in"); Status status = kvStore_->RegisterSyncCallback(callback); if (status != Status::SUCCESS) { callback->Clear(); @@ -572,6 +580,7 @@ napi_status JsKVStore::UnRegisterSyncCallback() { Status status = kvStore_->UnRegisterSyncCallback(); if (status != Status::SUCCESS) { + ZLOGE("unregister SyncCallback error status:%d", status); return napi_generic_failure; } std::lock_guard lck(listMutex_); @@ -586,7 +595,7 @@ napi_status JsKVStore::Subscribe(uint8_t type, std::shared_ptr obs { auto subscribeType = ToSubscribeType(type); Status status = kvStore_->SubscribeKvStore(subscribeType, observer); - ZLOGD("kvStore_->SubscribeKvStore(%{public}d) return %{public}d", type, status); + ZLOGD("kvStore_->SubscribeKvStore type=%{public}d, return status=%{public}d", type, status); if (status != Status::SUCCESS) { observer->Clear(); return napi_generic_failure; @@ -599,7 +608,7 @@ napi_status JsKVStore::UnSubscribe(uint8_t type, std::shared_ptr o { auto subscribeType = ToSubscribeType(type); Status status = kvStore_->UnSubscribeKvStore(subscribeType, observer); - ZLOGD("kvStore_->UnSubscribeKvStore(%{public}d) return %{public}d", type, status); + ZLOGD("kvStore_->UnSubscribeKvStore type=%{public}d, return status=%{public}d", type, status); if (status == Status::SUCCESS) { observer->Clear(); return napi_ok; @@ -615,14 +624,14 @@ void JsKVStore::SetUvQueue(std::shared_ptr uvQueue) void JsKVStore::DataObserver::OnChange(const ChangeNotification ¬ification, std::shared_ptr snapshot) { - ZLOGD("data change insert:%{public}zu, update:%{public}zu, delete:%{public}zu", + ZLOGD("data change insert=%{public}zu, update=%{public}zu, delete=%{public}zu", notification.GetInsertEntries().size(), notification.GetUpdateEntries().size(), notification.GetDeleteEntries().size()); } -void JsKVStore::DataObserver::OnChange(const ChangeNotification& notification) +void DataObserver::OnChange(const ChangeNotification& notification) { - ZLOGD("data change insert:%{public}zu, update:%{public}zu, delete:%{public}zu", + ZLOGD("data change insert=%{public}zu, update=%{public}zu, delete=%{public}zu", notification.GetInsertEntries().size(), notification.GetUpdateEntries().size(), notification.GetDeleteEntries().size()); KvStoreObserver::OnChange(notification); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp index 4605d44c7..3ca019cab 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp @@ -33,6 +33,7 @@ std::shared_ptr& JsKVStoreResultSet::GetNative() napi_value JsKVStoreResultSet::Constructor(napi_env env) { + ZLOGD("KVManager::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("getCount", JsKVStoreResultSet::GetCount), DECLARE_NAPI_FUNCTION("getPosition", JsKVStoreResultSet::GetPosition), @@ -188,7 +189,7 @@ napi_value JsKVStoreResultSet::MoveToPosition(napi_env env, napi_callback_info i }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - ZLOGD("KVStoreResultSet::MoveToPosition(%{public}d)", position); + ZLOGD("KVStoreResultSet::MoveToPosition position=%{public}d", position); auto& resultSet = reinterpret_cast(ctxt->native)->resultSet_; bool isMoved = resultSet->MoveToPosition(position); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_observer.cpp b/frameworks/jskitsimpl/distributeddata/src/js_observer.cpp deleted file mode 100644 index 394abf37d..000000000 --- a/frameworks/jskitsimpl/distributeddata/src/js_observer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "js_observer.h" - -namespace OHOS::DistributedData { -void JSObserver::Clear() -{ - // Clear() run in js main thread, so it serial run with AsyncCall() lambda, so we can use no lock. - if (callback_ == nullptr) { - return ; - } - napi_delete_reference(uvQueue_->GetEnv(), callback_); - callback_ = nullptr; -} - -JSObserver::JSObserver(std::shared_ptr uvQueue, napi_value callback) - : uvQueue_(uvQueue) -{ - napi_create_reference(uvQueue_->GetEnv(), callback, 1, &callback_); -} - -JSObserver::~JSObserver() -{ -} - -napi_ref JSObserver::GetCallback() -{ - return callback_; -} - -void JSObserver::AsyncCall(UvQueue::NapiArgsGenerator genArgs) -{ - if (callback_ == nullptr) { - return; - } - - uvQueue_->AsyncCall([observer = shared_from_this()](napi_env env) -> napi_value { - // the lambda run in js main thread, so it serial run with Clear(), so we can use no lock. - if (observer->callback_ == nullptr) { - return nullptr; - } - napi_value callback = nullptr; - napi_get_reference_value(env, observer->callback_, &callback); - return callback; - }, genArgs); -} -} \ No newline at end of file diff --git a/frameworks/jskitsimpl/distributeddata/src/js_query.cpp b/frameworks/jskitsimpl/distributeddata/src/js_query.cpp index 7f59047ed..d691f4ceb 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_query.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_query.cpp @@ -67,6 +67,7 @@ napi_value JsQuery::Constructor(napi_env env) */ napi_value JsQuery::New(napi_env env, napi_callback_info info) { + ZLOGD("Query::New()"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -346,6 +347,7 @@ struct NumbersContext : public ContextBase { napi_value JsQuery::InNumber(napi_env env, napi_callback_info info) { + ZLOGD("Query::InNumber()"); auto ctxt = std::make_shared(); ctxt->GetNumberSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -363,6 +365,7 @@ napi_value JsQuery::InNumber(napi_env env, napi_callback_info info) napi_value JsQuery::InString(napi_env env, napi_callback_info info) { + ZLOGD("Query::InString()"); struct StringsContext : public ContextBase { std::string field; std::vector valueList; @@ -386,6 +389,7 @@ napi_value JsQuery::InString(napi_env env, napi_callback_info info) napi_value JsQuery::NotInNumber(napi_env env, napi_callback_info info) { + ZLOGD("Query::NotInNumber()"); auto ctxt = std::make_shared(); ctxt->GetNumberSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -537,6 +541,7 @@ napi_value JsQuery::OrderByDesc(napi_env env, napi_callback_info info) napi_value JsQuery::Limit(napi_env env, napi_callback_info info) { + ZLOGD("Query::Limit()"); struct LimitContext : public ContextBase { int number; int offset; @@ -601,6 +606,7 @@ napi_value JsQuery::EndGroup(napi_env env, napi_callback_info info) napi_value JsQuery::PrefixKey(napi_env env, napi_callback_info info) { + ZLOGD("Query::PrefixKey()"); std::string prefix; auto ctxt = std::make_shared(); auto input = [env, ctxt, &prefix](size_t argc, napi_value* argv) { @@ -619,6 +625,7 @@ napi_value JsQuery::PrefixKey(napi_env env, napi_callback_info info) napi_value JsQuery::SetSuggestIndex(napi_env env, napi_callback_info info) { + ZLOGD("Query::SetSuggestIndex()"); std::string suggestIndex; auto ctxt = std::make_shared(); auto input = [env, ctxt, &suggestIndex](size_t argc, napi_value* argv) { @@ -637,6 +644,7 @@ napi_value JsQuery::SetSuggestIndex(napi_env env, napi_callback_info info) napi_value JsQuery::DeviceId(napi_env env, napi_callback_info info) { + ZLOGD("Query::DeviceId()"); std::string deviceId; auto ctxt = std::make_shared(); auto input = [env, ctxt, &deviceId](size_t argc, napi_value* argv) { @@ -656,6 +664,7 @@ napi_value JsQuery::DeviceId(napi_env env, napi_callback_info info) // getSqlLike():string napi_value JsQuery::GetSqlLike(napi_env env, napi_callback_info info) { + ZLOGD("Query::GetSqlLike()"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp b/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp index 5a457bb06..63e61c346 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp @@ -87,6 +87,7 @@ napi_status JsSchema::ToJson(napi_env env, napi_value inner, JsSchema*& out) JsSchema* JsSchema::GetSchema(napi_env env, napi_callback_info info, std::shared_ptr& ctxt) { + ZLOGD("Schema::GetSchema"); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); return reinterpret_cast(ctxt->native); @@ -95,6 +96,7 @@ JsSchema* JsSchema::GetSchema(napi_env env, napi_callback_info info, std::shared template napi_value JsSchema::GetContextValue(napi_env env, std::shared_ptr& ctxt, T& value) { + ZLOGD("Schema::GetContextValue"); JSUtil::SetValue(env, value, ctxt->output); return ctxt->output; } @@ -152,6 +154,7 @@ napi_value JsSchema::GetMode(napi_env env, napi_callback_info info) napi_value JsSchema::SetMode(napi_env env, napi_callback_info info) { + ZLOGD("Schema::SetMode"); auto ctxt = std::make_shared(); uint32_t mode = false; auto input = [env, ctxt, &mode](size_t argc, napi_value* argv) { @@ -178,6 +181,7 @@ napi_value JsSchema::GetSkip(napi_env env, napi_callback_info info) napi_value JsSchema::SetSkip(napi_env env, napi_callback_info info) { + ZLOGD("Schema::SetSkip"); auto ctxt = std::make_shared(); uint32_t skip = false; auto input = [env, ctxt, &skip](size_t argc, napi_value* argv) { @@ -204,6 +208,7 @@ napi_value JsSchema::GetIndexes(napi_env env, napi_callback_info info) napi_value JsSchema::SetIndexes(napi_env env, napi_callback_info info) { + ZLOGD("Schema::SetIndexes"); auto ctxt = std::make_shared(); std::vector indexes; auto input = [env, ctxt, &indexes](size_t argc, napi_value* argv) { diff --git a/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp index 1444f488b..b7d13e0cb 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp @@ -31,6 +31,7 @@ JsSingleKVStore::JsSingleKVStore(const std::string& storeId) napi_value JsSingleKVStore::Constructor(napi_env env) { + ZLOGD("JsSingleKVStore::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("put", JsKVStore::Put), DECLARE_NAPI_FUNCTION("delete", JsKVStore::Delete), @@ -162,11 +163,11 @@ napi_value JsSingleKVStore::GetEntries(napi_env env, napi_callback_info info) if (ctxt->va.type == ArgsType::KEYPREFIX) { OHOS::DistributedKv::Key keyPrefix(ctxt->va.keyPrefix); status = kvStore->GetEntries(keyPrefix, ctxt->entries); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetEntries() failed"); @@ -214,11 +215,11 @@ napi_value JsSingleKVStore::GetResultSet(napi_env env, napi_callback_info info) if (ctxt->va.type == ArgsType::KEYPREFIX) { OHOS::DistributedKv::Key keyPrefix(ctxt->va.keyPrefix); status = kvStore->GetResultSet(keyPrefix, kvResultSet); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetResultSet() failed!"); @@ -259,7 +260,7 @@ napi_value JsSingleKVStore::CloseResultSet(napi_env env, napi_callback_info info auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->CloseResultSet(ctxt->resultSet->GetNative()); - ZLOGD("kvStore->CloseResultSet return %{public}d", status); + ZLOGD("kvStore->CloseResultSet return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->CloseResultSet failed!"); }; @@ -293,7 +294,7 @@ napi_value JsSingleKVStore::GetResultSize(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); auto query = ctxt->query->GetNative(); Status status = kvStore->GetCountWithQuery(query.ToString(), ctxt->resultSize); - ZLOGD("kvStore->GetCountWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetCountWithQuery() return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetCountWithQuery() failed!"); }; @@ -327,7 +328,7 @@ napi_value JsSingleKVStore::RemoveDeviceData(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->RemoveDeviceData(ctxt->deviceId); - ZLOGD("kvStore->RemoveDeviceData return %{public}d", status); + ZLOGD("kvStore->RemoveDeviceData return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->RemoveDeviceData failed!"); }; @@ -362,12 +363,12 @@ napi_value JsSingleKVStore::Sync(napi_env env, napi_callback_info info) }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - ZLOGD("sync deviceIdList.size=%{public}d, mode:%{public}u, allowedDelayMs:%{public}u", + ZLOGD("sync deviceIdList.size=%{public}d, mode=%{public}u, allowedDelayMs=%{public}u", (int)ctxt->deviceIdList.size(), ctxt->mode, ctxt->allowedDelayMs); auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Sync(ctxt->deviceIdList, static_cast(ctxt->mode), ctxt->allowedDelayMs); - ZLOGD("kvStore->Sync return %{public}d!", status); + ZLOGD("kvStore->Sync return status=%{public}d!", status); NAPI_ASSERT(env, status == Status::SUCCESS, "kvStore->Sync() failed!"); return nullptr; } @@ -396,7 +397,7 @@ napi_value JsSingleKVStore::SetSyncParam(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); KvSyncParam syncParam { ctxt->allowedDelayMs }; Status status = kvStore->SetSyncParam(syncParam); - ZLOGD("kvStore->SetSyncParam return %{public}d", status); + ZLOGD("kvStore->SetSyncParam return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "output failed!"); }; @@ -420,7 +421,7 @@ napi_value JsSingleKVStore::GetSecurityLevel(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->GetSecurityLevel(ctxt->securityLevel); - ZLOGD("kvStore->GetSecurityLevel return %{public}d", status); + ZLOGD("kvStore->GetSecurityLevel return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "GetSecurityLevel failed!"); }; diff --git a/frameworks/jskitsimpl/distributeddata/src/js_util.cpp b/frameworks/jskitsimpl/distributeddata/src/js_util.cpp index 30addf604..f8e60df5f 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_util.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_util.cpp @@ -94,7 +94,7 @@ napi_status JSUtil::GetValue(napi_env env, napi_value in, std::string& out) if (maxLen <= 0) { return status; } - ZLOGD("napi_value -> std::string get length %{public}d", (int)maxLen); + ZLOGD("napi_value -> std::string get length=%{public}d", (int)maxLen); char* buf = new (std::nothrow) char[maxLen + STR_TAIL_LENGTH]; if (buf != nullptr) { size_t len = 0; @@ -164,7 +164,7 @@ JSUtil::KvStoreVariant JSUtil::Blob2VariantValue(const DistributedKv::Blob& blob } // number 1 means: skip the first byte, byte[0] is real data type. std::vector real(data.begin() + 1, data.end()); - ZLOGD("Blob::type %{public}d size=%{public}d", static_cast(data[0]), static_cast(real.size())); + ZLOGD("Blob::type=%{public}d size=%{public}d", static_cast(data[0]), static_cast(real.size())); if (data[0] == JSUtil::INTEGER) { uint32_t tmp4int = be32toh(*reinterpret_cast(&(real[0]))); return JSUtil::KvStoreVariant(*reinterpret_cast(&tmp4int)); @@ -971,6 +971,7 @@ napi_ref JSUtil::NewWithRef(napi_env env, size_t argc, napi_value* argv, void** napi_status JSUtil::Unwrap(napi_env env, napi_value in, void** out, napi_value constructor) { + ZLOGD("JSUtil::Unwrap"); if (constructor != nullptr) { bool isInstance = false; napi_instanceof(env, in, constructor, &isInstance); diff --git a/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp b/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp index e09d7ac17..da336ed6f 100644 --- a/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp @@ -119,10 +119,12 @@ void NapiQueue::GenerateOutput(ContextBase* ctxt) if (ctxt->status == napi_ok) { napi_get_undefined(ctxt->env, &result[RESULT_ERROR]); if (ctxt->output == nullptr) { + ZLOGD("ctxt->output is nullptr"); napi_get_undefined(ctxt->env, &ctxt->output); } result[RESULT_DATA] = ctxt->output; } else { + ZLOGD("ctxt->status != napi_ok"); napi_value message = nullptr; napi_create_string_utf8(ctxt->env, ctxt->error.c_str(), NAPI_AUTO_LENGTH, &message); napi_create_error(ctxt->env, nullptr, message, &result[RESULT_ERROR]); diff --git a/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp b/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp index 8a58d08c0..dcc564b38 100644 --- a/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp @@ -70,7 +70,7 @@ void UvQueue::AsyncCall(NapiCallbackGetter getter, NapiArgsGenerator genArgs) napi_value result; napi_status status = napi_call_function(entry->env, global, method, argc, argv, &result); if (status != napi_ok) { - ZLOGE("notify data change failed status:%{public}d callback:%{public}p", status, method); + ZLOGE("notify data change failed status=%{public}d callback=%{public}p", status, method); } }); } diff --git a/services/distributeddataservice/adapter/account/src/account_delegate.cpp b/services/distributeddataservice/adapter/account/src/account_delegate.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp b/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/src/constant.cpp b/services/distributeddataservice/adapter/autils/src/constant.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/src/directory_utils.cpp b/services/distributeddataservice/adapter/autils/src/directory_utils.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/src/kv_scheduler.cpp b/services/distributeddataservice/adapter/autils/src/kv_scheduler.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_task.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_task.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp old mode 100644 new mode 100755 index b3af3f038..6f9874a95 --- a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp +++ b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp @@ -21,6 +21,7 @@ namespace OHOS { namespace DistributedKv { KvStoreThread::KvStoreThread(KvStoreThreadPool *threadPool) + : pool_(threadPool) { realThread_ = std::thread([&, threadPool]() { // this makes me unconfortable: this lambda capture 'this' by reference, and right after this call this object @@ -30,6 +31,11 @@ KvStoreThread::KvStoreThread(KvStoreThreadPool *threadPool) }); } +KvStoreThread::KvStoreThread(KvStoreThread &&thread) : pool_(thread.pool_) +{ + realThread_ = std::move(thread.realThread_); +} + void KvStoreThread::Run(KvStoreThreadPool *pool) { if (pool == nullptr) { diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool_impl.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/autils/test/unittest/kv_scheduler_test.cpp b/services/distributeddataservice/adapter/autils/test/unittest/kv_scheduler_test.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender.cpp b/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender_impl.cpp b/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/app_device_handler.cpp b/services/distributeddataservice/adapter/communicator/src/app_device_handler.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp b/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp b/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/ark_communication_provider.cpp b/services/distributeddataservice/adapter/communicator/src/ark_communication_provider.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/communication_provider_impl.cpp b/services/distributeddataservice/adapter/communicator/src/communication_provider_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp b/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp old mode 100644 new mode 100755 index d15638598..c52686eb6 --- a/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp +++ b/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp @@ -19,14 +19,6 @@ namespace OHOS { namespace AppDistributedKv { int DataBuffer::sequence_ = 0; -const size_t DataBuffer::MAX_DATA_LEN = 1024 * 1024 * 5; - -const int DataBuffer::MAX_TRANSFER_SIZE = 1024 * 1024 * 5 - DataBuffer::HEADER_LEN; - -const uint32_t DataBuffer::VERSION = 0; - -const uint32_t DataBuffer::TYPE = 0; - DataBuffer::DataBuffer() : buf_(nullptr), size_(0), used_(0) {} diff --git a/services/distributeddataservice/adapter/communicator/src/process_communicator_impl.cpp b/services/distributeddataservice/adapter/communicator/src/process_communicator_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp old mode 100644 new mode 100755 index 70e2bfa3f..44504483f --- a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp +++ b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp @@ -689,7 +689,7 @@ void AppDataListenerWrap::OnSessionClosed(int sessionId) } ret = GetPeerSessionName(sessionId, peerSessionName, sizeof(peerSessionName)); if (ret != SOFTBUS_OK) { - ZLOGW("get my peer session name failed."); + ZLOGW("get my peer session name failed, session id is %{public}d.", sessionId); return; } ret = GetPeerDeviceId(sessionId, peerDevId, sizeof(peerDevId)); diff --git a/services/distributeddataservice/adapter/dfx/src/dds_trace.cpp b/services/distributeddataservice/adapter/dfx/src/dds_trace.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/reporter.cpp b/services/distributeddataservice/adapter/dfx/src/reporter.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/permission/src/client_permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/client_permission_validator.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/permission/test/unittest/permission_validator_test.cpp b/services/distributeddataservice/adapter/permission/test/unittest/permission_validator_test.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/adapter/utils/src/kvstore_utils.cpp b/services/distributeddataservice/adapter/utils/src/kvstore_utils.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/backup_handler.cpp b/services/distributeddataservice/app/src/backup_handler.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp b/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_account_observer.cpp b/services/distributeddataservice/app/src/kvstore_account_observer.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_app_accessor.cpp b/services/distributeddataservice/app/src/kvstore_app_accessor.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_app_manager.cpp b/services/distributeddataservice/app/src/kvstore_app_manager.cpp old mode 100644 new mode 100755 index 1183f916e..d46d36494 --- a/services/distributeddataservice/app/src/kvstore_app_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_app_manager.cpp @@ -436,7 +436,7 @@ KvStoreAppManager::PathType KvStoreAppManager::ConvertPathType(int32_t uid, cons default: break; } - auto *checker = CheckerManager::GetInstance().GetChecker(CheckerManager::SYSTEM_CHECKER); + auto *checker = CheckerManager::GetInstance().GetChecker("SystemChecker"); if (checker == nullptr || !checker->IsValid(uid, bundleName)) { return PATH_CE; } diff --git a/services/distributeddataservice/app/src/kvstore_impl.cpp b/services/distributeddataservice/app/src/kvstore_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_resultset_impl.cpp b/services/distributeddataservice/app/src/kvstore_resultset_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_snapshot_impl.cpp b/services/distributeddataservice/app/src/kvstore_snapshot_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_sync_manager.cpp b/services/distributeddataservice/app/src/kvstore_sync_manager.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/kvstore_user_manager.cpp b/services/distributeddataservice/app/src/kvstore_user_manager.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/security/security.cpp b/services/distributeddataservice/app/src/security/security.cpp index 1f1e96529..3874ac43b 100644 --- a/services/distributeddataservice/app/src/security/security.cpp +++ b/services/distributeddataservice/app/src/security/security.cpp @@ -164,6 +164,7 @@ Sensitive Security::GetSensitiveByUuid(const std::string &uuid) sensitive = value; return true; } + auto &network = AppDistributedKv::CommunicationProvider::GetInstance(); auto devices = network.GetRemoteNodesBasicInfo(); devices.push_back(network.GetLocalBasicInfo()); diff --git a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp index 513e8e550..2158affa1 100644 --- a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp +++ b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp @@ -212,10 +212,6 @@ bool RouteHeadHandlerImpl::UnPackData(const uint8_t *data, uint32_t totalLen, ui bool RouteHeadHandlerImpl::UnPackDataHead(const uint8_t *data, uint32_t totalLen, RouteHead &routeHead) { - if (totalLen < sizeof(RouteHead)) { - ZLOGE("invalid route head len"); - return false; - } const RouteHead *head = reinterpret_cast(data); routeHead.magic = NetToHost(head->magic); routeHead.version = NetToHost(head->version); @@ -225,8 +221,8 @@ bool RouteHeadHandlerImpl::UnPackDataHead(const uint8_t *data, uint32_t totalLen ZLOGW("not route head data"); return false; } - if (totalLen - sizeof(RouteHead) < routeHead.dataLen) { - ZLOGE("invalid route data len"); + if (routeHead.dataLen + sizeof(RouteHead) > totalLen) { + ZLOGE("invalid route head len"); return false; } return true; @@ -254,16 +250,14 @@ bool RouteHeadHandlerImpl::UnPackDataBody(const uint8_t *data, uint32_t totalLen const SessionUserPair *userPair = reinterpret_cast(ptr); session_.sourceUserId = NetToHost(userPair->sourceUserId); - auto userPairSize = sizeof(SessionUserPair) + userPair->targetUserCount * sizeof(uint32_t); - if (leftSize < userPairSize) { + if (leftSize < sizeof(SessionUserPair) + userPair->targetUserCount * sizeof(int)) { ZLOGE("failed to parse user pair, target user"); return false; } for (int i = 0; i < userPair->targetUserCount; ++i) { session_.targetUserIds.push_back(NetToHost(*(userPair->targetUserIds + i))); } - ptr += userPairSize; - leftSize -= userPairSize; + ptr += sizeof(SessionUserPair) + userPair->targetUserCount * sizeof(int); if (leftSize < sizeof(SessionAppId)) { ZLOGE("failed to parse app id len"); @@ -271,7 +265,7 @@ bool RouteHeadHandlerImpl::UnPackDataBody(const uint8_t *data, uint32_t totalLen } const SessionAppId *appId = reinterpret_cast(ptr); auto appIdLen = NetToHost(appId->len); - if (leftSize - sizeof(SessionAppId) < appIdLen) { + if (leftSize < sizeof(SessionAppId) + appIdLen) { ZLOGE("failed to parse app id"); return false; } diff --git a/services/distributeddataservice/app/src/session_manager/session_manager.cpp b/services/distributeddataservice/app/src/session_manager/session_manager.cpp index 16b4bba46..1f54406b0 100644 --- a/services/distributeddataservice/app/src/session_manager/session_manager.cpp +++ b/services/distributeddataservice/app/src/session_manager/session_manager.cpp @@ -17,8 +17,6 @@ #define LOG_TAG "SessionManager" -#include - #include "auth/auth_delegate.h" #include "checker/checker_manager.h" #include "log/log_print.h" @@ -41,23 +39,11 @@ Session SessionManager::GetSession(const SessionPoint &from, const std::string & session.sourceUserId = from.userId; session.sourceDeviceId = from.deviceId; session.targetDeviceId = targetDeviceId; - - // system service - if (from.userId == UserDelegate::SYSTEM_USER) { - auto *checker = CheckerManager::GetInstance().GetChecker(CheckerManager::SYSTEM_CHECKER); - if (checker != nullptr && checker->IsValid(UserDelegate::SYSTEM_USER, from.appId)) { - session.targetUserIds.push_back(UserDelegate::SYSTEM_USER); - } - } - for (const auto &user : users) { bool isPermitted = AuthDelegate::GetInstance()->CheckAccess(from.userId, user.id, targetDeviceId, from.appId); ZLOGD("access to peer user %{public}d is %{public}d", user.id, isPermitted); if (isPermitted) { - auto it = std::find(session.targetUserIds.begin(), session.targetUserIds.end(), user.id); - if (it == session.targetUserIds.end()) { - session.targetUserIds.push_back(user.id); - } + session.targetUserIds.push_back(user.id); } } ZLOGD("end"); diff --git a/services/distributeddataservice/app/src/single_kvstore_impl.cpp b/services/distributeddataservice/app/src/single_kvstore_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/uninstaller/uninstaller.cpp b/services/distributeddataservice/app/src/uninstaller/uninstaller.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/app/src/uninstaller/uninstaller_impl.cpp b/services/distributeddataservice/app/src/uninstaller/uninstaller_impl.cpp old mode 100644 new mode 100755 diff --git a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp index 3ad52cb03..979b3dd4f 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp @@ -143,7 +143,7 @@ int AutoLaunch::EnableKvStoreAutoLaunchParmCheck(AutoLaunchItem &autoLaunchItem, return -E_ALREADY_SET; } uint32_t autoLaunchItemSize = 0; - for (const auto &item : autoLaunchItemMap_) { + for (const auto item : autoLaunchItemMap_) { autoLaunchItemSize += item.second.size(); } if (autoLaunchItemSize == MAX_AUTO_LAUNCH_ITEM_NUM) { @@ -206,6 +206,7 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st return E_OK; } if (autoLaunchItem.conn == nullptr) { + LOGE("[AutoLaunch] GetKVConnectionInEnable GetDatabaseConnection errCode:%d", errCode); std::lock_guard autoLock(dataLock_); EraseAutoLauchItem(identifier, userId); return errCode; @@ -235,6 +236,7 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IDLE; autoLaunchItemMap_[identifier][userId].conn = autoLaunchItem.conn; autoLaunchItemMap_[identifier][userId].observerHandle = autoLaunchItem.observerHandle; + LOGI("[AutoLaunch] GetKVConnectionInEnable RegisterObserverAndLifeCycleCallback ok"); } else { LOGE("[AutoLaunch] GetKVConnectionInEnable RegisterObserverAndLifeCycleCallback err, do CloseConnection"); TryCloseConnection(autoLaunchItem); // do nothing if failed @@ -827,27 +829,21 @@ void AutoLaunch::AutoLaunchExtTask(const std::string identifier, const std::stri } extItemMap_[identifier][userId] = autoLaunchItem; } - bool abort = false; - do { - int errCode = CheckAutoLaunchRealPath(autoLaunchItem); - if (errCode != E_OK) { - abort = true; - break; - } - errCode = OpenOneConnection(autoLaunchItem); - LOGI("[AutoLaunch] AutoLaunchExtTask GetOneConnection errCode:%d", errCode); - if (autoLaunchItem.conn == nullptr) { - abort = true; - break; - } - errCode = RegisterObserverAndLifeCycleCallback(autoLaunchItem, identifier, true); - if (errCode != E_OK) { - LOGE("[AutoLaunch] AutoLaunchExtTask RegisterObserverAndLifeCycleCallback failed"); - TryCloseConnection(autoLaunchItem); // if here failed, do nothing - abort = true; + int errCode = OpenOneConnection(autoLaunchItem); + LOGI("[AutoLaunch] AutoLaunchExtTask GetOneConnection errCode:%d", errCode); + if (autoLaunchItem.conn == nullptr) { + std::lock_guard autoLock(extLock_); + extItemMap_[identifier].erase(userId); + if (extItemMap_[identifier].size() == 0) { + extItemMap_.erase(identifier); } - } while (false); - if (abort) { + return; + } + + errCode = RegisterObserverAndLifeCycleCallback(autoLaunchItem, identifier, true); + if (errCode != E_OK) { + LOGE("[AutoLaunch] AutoLaunchExtTask RegisterObserverAndLifeCycleCallback failed"); + TryCloseConnection(autoLaunchItem); // if here failed, do nothing std::lock_guard autoLock(extLock_); extItemMap_[identifier].erase(userId); if (extItemMap_[identifier].size() == 0) { @@ -1085,6 +1081,14 @@ int AutoLaunch::OpenKvConnection(AutoLaunchItem &autoLaunchItem) std::shared_ptr properties = std::static_pointer_cast(autoLaunchItem.propertiesPtr); int errCode = E_OK; + std::string canonicalDir; + std::string dataDir; + properties->GetStringProp(KvDBProperties::DATA_DIR, dataDir); + if (!ParamCheckUtils::CheckDataDir(dataDir, canonicalDir)) { + LOGE("[AutoLaunch] CheckDataDir is invalid Auto Launch failed."); + return -E_INVALID_ARGS; + } + properties->SetStringProp(KvDBProperties::DATA_DIR, canonicalDir); IKvDBConnection *conn = KvDBManager::GetDatabaseConnection(*properties, errCode, false); if (errCode == -E_ALREADY_OPENED) { LOGI("[AutoLaunch] GetOneConnection user already getkvstore by self"); @@ -1206,33 +1210,4 @@ void AutoLaunch::EraseAutoLauchItem(const std::string &identifier, const std::st autoLaunchItemMap_.erase(identifier); } } - -void AutoLaunch::NotifyInvalidParam(const AutoLaunchItem &autoLaunchItem) -{ - if (!autoLaunchItem.notifier) { - return; - } - int retCode = RuntimeContext::GetInstance()->ScheduleTask([autoLaunchItem] { - std::string userId = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::USER_ID, ""); - std::string appId = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::APP_ID, ""); - std::string storeId = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::STORE_ID, ""); - autoLaunchItem.notifier(userId, appId, storeId, INVALID_PARAM); - }); - if (retCode != E_OK) { - LOGE("[AutoLaunch] AutoLaunchExt notifier ScheduleTask retCode:%d", retCode); - } -} - -int AutoLaunch::CheckAutoLaunchRealPath(const AutoLaunchItem &autoLaunchItem) -{ - std::string canonicalDir; - std::string dataDir = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::DATA_DIR, ""); - if (!ParamCheckUtils::CheckDataDir(dataDir, canonicalDir)) { - LOGE("[AutoLaunch] CheckDataDir is invalid Auto Launch failed."); - NotifyInvalidParam(autoLaunchItem); - return -E_INVALID_ARGS; - } - autoLaunchItem.propertiesPtr->SetStringProp(DBProperties::DATA_DIR, canonicalDir); - return E_OK; -} } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp b/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp index 54c3b82f2..1d498a370 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp @@ -28,6 +28,7 @@ bool ParamCheckUtils::CheckDataDir(const std::string &dataDir, std::string &cano } if (OS::GetRealPath(dataDir, canonicalDir) != E_OK) { + LOGE("Failed to canonicalize the data dir."); return false; } // After normalizing the path, determine whether the path is a legal path considered by the program. diff --git a/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp b/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp index e3b2f58e5..01f32ea65 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp @@ -144,7 +144,7 @@ int GetRealPath(const std::string &inOriPath, std::string &outRealPath) } if (realpath(inOriPath.c_str(), realPath) == nullptr) { - LOGE("[OS] Realpath error:%d.", errno); + LOGE("[RealPath] Get realpath for inOriPath fail:%d.", errno); delete []realPath; return -E_SYSTEM_API_FAIL; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp index 0a2161a96..0937ecb35 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp @@ -47,7 +47,7 @@ int Communicator::RegOnConnectCallback(const OnConnectCallback &onConnect, const if (onConnect && errCode == E_OK) { // Register action and success for (auto &entry : onlineTargets_) { - LOGI("[Comm][RegConnect] Label=%.6s, online target=%s{private}.", VEC_TO_STR(commLabel_), entry.c_str()); + LOGI("[Comm][RegConnect] Label=%s, online target=%s{private}.", VEC_TO_STR(commLabel_), entry.c_str()); onConnectHandle_(entry, true); } } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp index 1ec0fa24a..5614b31a9 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp @@ -136,7 +136,7 @@ ICommunicator *CommunicatorAggregator::AllocCommunicator(uint64_t commLabel, int ICommunicator *CommunicatorAggregator::AllocCommunicator(const std::vector &commLabel, int &outErrorNo) { std::lock_guard commMapLockGuard(commMapMutex_); - LOGI("[CommAggr][Alloc] Label=%.6s.", VEC_TO_STR(commLabel)); + LOGI("[CommAggr][Alloc] Label=%s.", VEC_TO_STR(commLabel)); if (commLabel.size() != COMM_LABEL_LENGTH) { outErrorNo = -E_INVALID_ARGS; return nullptr; @@ -163,7 +163,7 @@ void CommunicatorAggregator::ReleaseCommunicator(ICommunicator *inCommunicator) } Communicator *commPtr = static_cast(inCommunicator); LabelType commLabel = commPtr->GetCommunicatorLabel(); - LOGI("[CommAggr][Release] Label=%.6s.", VEC_TO_STR(commLabel)); + LOGI("[CommAggr][Release] Label=%s.", VEC_TO_STR(commLabel)); std::lock_guard commMapLockGuard(commMapMutex_); if (commMap_.count(commLabel) == 0) { @@ -234,7 +234,7 @@ int CommunicatorAggregator::GetLocalIdentity(std::string &outTarget) const void CommunicatorAggregator::ActivateCommunicator(const LabelType &commLabel) { std::lock_guard commMapLockGuard(commMapMutex_); - LOGI("[CommAggr][Activate] Label=%.6s.", VEC_TO_STR(commLabel)); + LOGI("[CommAggr][Activate] Label=%s.", VEC_TO_STR(commLabel)); if (commMap_.count(commLabel) == 0) { LOGW("[CommAggr][Activate] Communicator of this label not allocated."); return; diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp index 93c7e14a9..f0b4f6302 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp @@ -399,16 +399,6 @@ int ProtocolProto::SetDivergeHeader(SerialBuffer *inBuff, const LabelType &inCom return E_OK; } -namespace { -void FillPhyHeaderLenInfo(CommPhyHeader &header, uint32_t packetLen, uint64_t sum, uint8_t type, uint8_t paddingLen) -{ - header.packetLen = packetLen; - header.checkSum = sum; - header.packetType |= type; - header.paddingLen = paddingLen; -} -} - int ProtocolProto::SetPhyHeader(SerialBuffer *inBuff, const PhyHeaderInfo &inInfo) { if (inBuff == nullptr) { @@ -433,11 +423,13 @@ int ProtocolProto::SetPhyHeader(SerialBuffer *inBuff, const PhyHeaderInfo &inInf CommPhyHeader phyHeader; phyHeader.magic = MAGIC_CODE; phyHeader.version = PROTOCOL_VERSION; + phyHeader.packetLen = packetLen; + phyHeader.checkSum = 0; // Sum is calculated afterwards phyHeader.sourceId = inInfo.sourceId; phyHeader.frameId = inInfo.frameId; - phyHeader.packetType = 0; + phyHeader.packetType = packetType; + phyHeader.paddingLen = paddingLen; phyHeader.dbIntVer = DB_GLOBAL_VERSION; - FillPhyHeaderLenInfo(phyHeader, packetLen, 0, packetType, paddingLen); // Sum is calculated afterwards HeaderConverter::ConvertHostToNet(phyHeader, phyHeader); errno_t retCode = memcpy_s(headerByteLen.first, headerByteLen.second, &phyHeader, sizeof(CommPhyHeader)); @@ -942,8 +934,8 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram for (auto &entry : outPieces) { // subtract 1 for index uint32_t pieceFragLen = (fragNo != fragmentInfo.fragCount - 1) ? quotient : (quotient + remainder); - uint32_t alignedFragLen = BYTE_8_ALIGN(pieceFragLen); // Add padding length - uint32_t pieceTotalLen = alignedFragLen + sizeof(CommPhyHeader) + sizeof(CommPhyOptHeader); + uint32_t alignedPieceFragLen = BYTE_8_ALIGN(pieceFragLen); // Add padding length + uint32_t pieceTotalLen = alignedPieceFragLen + sizeof(CommPhyHeader) + sizeof(CommPhyOptHeader); // Since exception is disabled, we have to check the vector size to assure that memory is truly allocated entry.first.resize(pieceTotalLen + fragmentInfo.extendHeadSize); // Note: should use resize other than reserve @@ -954,10 +946,10 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram CommPhyHeader pktPhyHeader; HeaderConverter::ConvertNetToHost(framePhyHeader, pktPhyHeader); // Restore to host endian - - // The sum value need to be recalculated, and the packet is fragmented. - // The alignedFragLen is always larger than pieceFragLen - FillPhyHeaderLenInfo(pktPhyHeader, pieceTotalLen, 0, PACKET_TYPE_FRAGMENTED, alignedFragLen - pieceFragLen); + pktPhyHeader.packetLen = pieceTotalLen; + pktPhyHeader.checkSum = 0; // The sum value need to be recalculate + pktPhyHeader.packetType |= PACKET_TYPE_FRAGMENTED; // Set the FragmentedFlag bit + pktPhyHeader.paddingLen = alignedPieceFragLen - pieceFragLen; // The former is always larger than latter HeaderConverter::ConvertHostToNet(pktPhyHeader, pktPhyHeader); CommPhyOptHeader pktPhyOptHeader = {static_cast(fragmentInfo.splitLength + sizeof(CommPhyHeader)), diff --git a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp index d79127f57..2d44ee6c7 100644 --- a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp @@ -57,7 +57,7 @@ DBStatus RelationalStoreDelegateImpl::CreateDistributedTable(const std::string & int errCode = conn_->CreateDistributedTable(tableName); if (errCode != E_OK) { - LOGE("[RelationalStore Delegate] Create Distributed table failed:%d", errCode); + LOGW("[RelationalStore Delegate] Create Distributed table failed:%d", errCode); return TransferDBErrno(errCode); } return OK; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp index 5a12f0a13..4c6a0fc53 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp @@ -519,6 +519,7 @@ int DatabaseOper::ClearImportTempFile(const KvDBProperties &property) const std::string exportBackupDir = workDir + "/" + dbSubDir + DBConstant::PATH_POSTFIX_UNPACKED; DBCommon::RemoveAllFilesOfDirectory(exportBackupDir); + LOGI("Clear the files while import"); if (isOriKeepFileExist && isBakKeepFileExist) { LOGE("Origin and backup file shouldn't exist concurrently"); } @@ -555,6 +556,7 @@ int DatabaseOper::ClearExportedTempFiles(const KvDBProperties &property) const int dbType = property.GetIntProp(KvDBProperties::DATABASE_TYPE, KvDBProperties::LOCAL_TYPE); std::string dbSubDir = KvDBProperties::GetStoreSubDirectory(dbType); std::string backupDir = workDir + "/" + dbSubDir + DBConstant::PATH_POSTFIX_EXPORT_BACKUP; + LOGI("Remove the exported files."); errCode = DBCommon::RemoveAllFilesOfDirectory(backupDir); if (errCode != E_OK) { LOGE("Remove the exported backup dir failed"); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp index 55c749d27..bc77775f8 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp @@ -22,6 +22,10 @@ namespace DistributedDB { namespace { const int INVALID_LIMIT = INT_MAX; const int LIMIT_FIELD_VALUE_SIZE = 2; +bool IsNeedCheckEqualFormat(SymbolType type) +{ + return type == COMPARE_SYMBOL || type == RELATIONAL_SYMBOL || type == RANGE_SYMBOL; +} } QueryObject::QueryObject() @@ -208,63 +212,45 @@ int QueryObject::ParseQueryObjNodes() int QueryObject::ParseNode(const std::list::iterator &iter) { + SymbolType symbolType = SqliteQueryHelper::GetSymbolType(iter->operFlag); // The object is newly instantiated in the connection, and there is no reentrancy problem. - if (!iter->IsValid()) { + if (symbolType == PREFIXKEY_SYMBOL && hasPrefixKey_) { + LOGE("Only filter by prefix key once!!"); return -E_INVALID_QUERY_FORMAT; } - switch (SqliteQueryHelper::GetSymbolType(iter->operFlag)) { - case COMPARE_SYMBOL: - case RELATIONAL_SYMBOL: - case RANGE_SYMBOL: - return CheckEqualFormat(iter); - case LINK_SYMBOL: - return CheckLinkerFormat(iter); - case PREFIXKEY_SYMBOL: { - if (hasPrefixKey_) { - LOGE("Only filter by prefix key once!!"); - return -E_INVALID_QUERY_FORMAT; - } - hasPrefixKey_ = true; - if (prefixKey_.size() > DBConstant::MAX_KEY_SIZE) { - return -E_INVALID_ARGS; - } - return E_OK; + if (iter->operFlag == QueryObjType::OPER_ILLEGAL || iter->type == QueryValueType::VALUE_TYPE_INVALID) { + return -E_INVALID_QUERY_FORMAT; + } else if (IsNeedCheckEqualFormat(symbolType)) { + return CheckEqualFormat(iter); + } else if (symbolType == LINK_SYMBOL) { + return CheckLinkerFormat(iter); + } else if (iter->operFlag == QueryObjType::LIMIT) { + hasLimit_ = true; + if (iter->fieldValue.size() == LIMIT_FIELD_VALUE_SIZE) { + limit_ = iter->fieldValue[0].integerValue; + offset_ = iter->fieldValue[1].integerValue; } - case SUGGEST_INDEX_SYMBOL: - return CheckSuggestIndexFormat(iter); - case IN_KEYS_SYMBOL: { - if (hasInKeys_) { - LOGE("Only filter by keys in once!!"); - return -E_INVALID_QUERY_FORMAT; - } - int errCode = CheckInKeys(); - if (errCode != E_OK) { - return errCode; - } - hasInKeys_ = true; - return E_OK; + return CheckLimitFormat(iter); + } else if (iter->operFlag == QueryObjType::ORDERBY) { + return CheckOrderByFormat(iter); + } else if (symbolType == PREFIXKEY_SYMBOL) { + hasPrefixKey_ = true; + if (prefixKey_.size() > DBConstant::MAX_KEY_SIZE) { + return -E_INVALID_ARGS; } - default: - return ParseNodeByOperFlag(iter); - } - return E_OK; -} - -int QueryObject::ParseNodeByOperFlag(const std::list::iterator &iter) -{ - switch (iter->operFlag) { - case QueryObjType::LIMIT: - hasLimit_ = true; - if (iter->fieldValue.size() == LIMIT_FIELD_VALUE_SIZE) { - limit_ = iter->fieldValue[0].integerValue; - offset_ = iter->fieldValue[1].integerValue; - } - return CheckLimitFormat(iter); - case QueryObjType::ORDERBY: - return CheckOrderByFormat(iter); - default: - return E_OK; + } else if (symbolType == SUGGEST_INDEX_SYMBOL) { + return CheckSuggestIndexFormat(iter); + } else if (symbolType == IN_KEYS_SYMBOL) { + if (hasInKeys_) { + LOGE("Only filter by keys in once!!"); + return -E_INVALID_QUERY_FORMAT; + } + int errCode = CheckInKeys(); + if (errCode != E_OK) { + return errCode; + } + hasInKeys_ = true; } return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp index 90a535bec..cd4492dc3 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp @@ -169,11 +169,15 @@ std::string QuerySyncObject::GetIdentify() const (void)parcel.WriteVectorChar(key); } // QUERY_SYNC_OBJECT_VERSION_1 end. - std::vector hashBuff; - if (parcel.IsError() || DBCommon::CalcValueHash(buff, hashBuff) != E_OK) { + if (parcel.IsError()) { return std::string(); } + std::vector hashBuff; + int errCode = DBCommon::CalcValueHash(buff, hashBuff); + if (errCode != E_OK) { + return std::string(); + } return DBCommon::VectorToHexString(hashBuff); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp index c43ef227d..be2cc3b9e 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp @@ -93,6 +93,7 @@ int SQLiteRelationalStoreConnection::StartTransaction() return errCode; } + LOGD("[RelationalConnection] Start transaction finish."); writeHandle_ = handle; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp index f0ff27eed..70d7cec2c 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp @@ -188,8 +188,8 @@ int SQLiteSingleVerDatabaseUpgrader::UpgradeFromDatabaseVersion(int version) { std::vector sqls; bool isCreateUpgradeFile = false; - LOGI("[SqlSingleUp] metaSplit[%d], secLabel[%d], secFlag[%d]", - isMetaUpgrade_, secOpt_.securityLabel, secOpt_.securityFlag); + LOGI("[SqlSingleUp]version=%d, metaSplit[%d], secLabel[%d], secFlag[%d]", + version, isMetaUpgrade_, secOpt_.securityLabel, secOpt_.securityFlag); SetUpgradeSqls(version, sqls, isCreateUpgradeFile); for (const auto &item : sqls) { int errCode = SQLiteUtils::ExecuteRawSQL(db_, item); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp index 69c31c089..7a75c0807 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp @@ -148,8 +148,7 @@ namespace { size_t appendLen) { bool reachThreshold = false; - size_t blockSize = 0; - for (size_t i = 0; !reachThreshold && i < dataItems.size(); i++) { + for (size_t i = 0, blockSize = 0; !reachThreshold && i < dataItems.size(); i++) { blockSize += SQLiteSingleVerStorageExecutor::GetDataItemSerialSize(dataItems[i], appendLen); reachThreshold = (blockSize >= dataSizeInfo.blockSize * DBConstant::QUERY_SYNC_THRESHOLD); } @@ -1249,7 +1248,6 @@ int SQLiteSingleVerNaturalStore::SaveSyncItems(const QueryObject &query, std::ve ReleaseHandle(handle); return errCode; } - bool isPermitForceWrite = !(GetDbProperties().GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false)); errCode = handle->CheckDataWithQuery(query, dataItems, deviceInfo); if (errCode != E_OK) { goto END; @@ -1262,7 +1260,7 @@ int SQLiteSingleVerNaturalStore::SaveSyncItems(const QueryObject &query, std::ve if (item.neglect) { // Do not save this record if it is neglected continue; } - errCode = handle->SaveSyncDataItem(item, deviceInfo, maxTimestamp, commitData, isPermitForceWrite); + errCode = handle->SaveSyncDataItem(item, deviceInfo, maxTimestamp, commitData); if (errCode != E_OK && errCode != -E_NOT_FOUND) { break; } @@ -1610,7 +1608,7 @@ int SQLiteSingleVerNaturalStore::GetSchema(SchemaObject &schema) const std::string schemaValue(value.begin(), value.end()); errCode = schema.ParseFromSchemaString(schemaValue); } else { - LOGI("[SqlSinStore] Get schema error:%d.", errCode); + LOGI("[SqlSinStore][GetSchema] Get schema from db failed or no schema=%d.", errCode); } ReleaseHandle(handle); return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index 54234478d..c5abe7bc4 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -375,7 +375,12 @@ int SQLiteSingleVerNaturalStoreConnection::Pragma(int cmd, void *parameter) if (parameter == nullptr) { return -E_INVALID_ARGS; } - return CalcHashDevID(*(static_cast(parameter))); + if (static_cast(parameter)->deviceID == "") { + return -E_INVALID_ARGS; + } + static_cast(parameter)->deviceIdentifier = + DBCommon::TransferHashString(static_cast(parameter)->deviceID); + break; } case PRAGMA_GET_DEVICE_IDENTIFIER_OF_ENTRY: return GetDeviceIdentifier(static_cast(parameter)); @@ -1258,6 +1263,7 @@ int SQLiteSingleVerNaturalStoreConnection::StartTransactionInCacheMode() return errCode; } + LOGD("[SingleVerConnection] Start transaction finish in cache mode."); writeHandle_ = handle; transactionEntrySize_ = 0; return E_OK; @@ -1300,6 +1306,7 @@ int SQLiteSingleVerNaturalStoreConnection::StartTransactionNormally() return errCode; } + LOGD("[SingleVerConnection] Start transaction finish."); writeHandle_ = handle; transactionEntrySize_ = 0; return E_OK; @@ -1317,7 +1324,7 @@ void SQLiteSingleVerNaturalStoreConnection::InitConflictNotifiedFlag() if (kvDB_->GetRegisterFunctionCount(CONFLICT_SINGLE_VERSION_NS_NATIVE_ALL) != 0) { conflictFlag |= static_cast(SQLITE_GENERAL_NS_NATIVE_ALL); } - + LOGD("[SingleVer][InitConflictNotifiedFlag] conflictFlag Flag: %u", conflictFlag); committedData_->SetConflictedNotifiedFlag(static_cast(conflictFlag)); } @@ -1327,6 +1334,7 @@ int SQLiteSingleVerNaturalStoreConnection::CommitInner() int errCode = writeHandle_->Commit(); ReleaseExecutor(writeHandle_); + LOGD("Commit transaction finish."); transactionEntrySize_ = 0; if (!isCacheOrMigrating) { @@ -1348,6 +1356,7 @@ int SQLiteSingleVerNaturalStoreConnection::CommitInner() int SQLiteSingleVerNaturalStoreConnection::RollbackInner() { int errCode = writeHandle_->Rollback(); + LOGD("Rollback transaction finish."); transactionEntrySize_ = 0; currentMaxTimeStamp_ = 0; if (!IsExtendedCacheDBMode()) { @@ -1363,7 +1372,7 @@ SQLiteSingleVerStorageExecutor *SQLiteSingleVerNaturalStoreConnection::GetExecut SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { errCode = -E_NOT_INIT; - LOGE("[SingleVerConnection] the store is null"); + LOGE("[SingleVerConnection] Kvstore is null, get executor failed! errCode = [%d]", errCode); return nullptr; } return naturalStore->GetHandle(isWrite, errCode); @@ -1373,7 +1382,7 @@ bool SQLiteSingleVerNaturalStoreConnection::IsCacheDBMode() const { SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { - LOGE("[SingleVerConnection] the store is null"); + LOGE("[SingleVerConnection] natural store is null in IsCacheDBMode."); return false; } return naturalStore->IsCacheDBMode(); @@ -1383,7 +1392,7 @@ bool SQLiteSingleVerNaturalStoreConnection::IsExtendedCacheDBMode() const { SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { - LOGE("[SingleVerConnection] the store is null"); + LOGE("[SingleVerConnection] natural store is nullptr in IsExtendedCacheDBMode."); return false; } return naturalStore->IsExtendedCacheDBMode(); @@ -1755,14 +1764,5 @@ bool SQLiteSingleVerNaturalStoreConnection::CheckLogOverLimit(SQLiteSingleVerSto return result; } -int SQLiteSingleVerNaturalStoreConnection::CalcHashDevID(PragmaDeviceIdentifier &pragmaDev) -{ - if (pragmaDev.deviceID.empty()) { - return -E_INVALID_ARGS; - } - pragmaDev.deviceIdentifier = DBCommon::TransferHashString(pragmaDev.deviceID); - return E_OK; -} - DEFINE_OBJECT_TAG_FACILITIES(SQLiteSingleVerNaturalStoreConnection) } \ No newline at end of file diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp index 3ca30a82b..7d85f0743 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp @@ -625,13 +625,14 @@ int SQLiteSingleVerRelationalStorageExecutor::PrepareForSavingLog(const QueryObj int errCode = SQLiteUtils::GetStatement(dbHandle_, sql, logStmt); if (errCode != E_OK) { LOGE("[info statement] Get log statement fail! errCode:%d", errCode); - return errCode; + return -E_INVALID_QUERY_FORMAT; } std::string selectSql = "select " + columnList + " from " + tableName + " where hash_key = ? and device = ?;"; errCode = SQLiteUtils::GetStatement(dbHandle_, selectSql, queryStmt); if (errCode != E_OK) { SQLiteUtils::ResetStatement(logStmt, true, errCode); LOGE("[info statement] Get query statement fail! errCode:%d", errCode); + return -E_INVALID_QUERY_FORMAT; } return errCode; } @@ -653,6 +654,7 @@ int SQLiteSingleVerRelationalStorageExecutor::PrepareForSavingData(const QueryOb int errCode = SQLiteUtils::GetStatement(dbHandle_, sql, statement); if (errCode != E_OK) { LOGE("[info statement] Get saving data statement fail! errCode:%d", errCode); + errCode = -E_INVALID_QUERY_FORMAT; } return errCode; } @@ -716,8 +718,8 @@ int SQLiteSingleVerRelationalStorageExecutor::DeleteSyncDataItem(const DataItem "WHERE hash_key=? AND device=? AND flag&0x01=0);"; int errCode = SQLiteUtils::GetStatement(dbHandle_, sql, stmt); if (errCode != E_OK) { - LOGE("[DeleteSyncDataItem] Get statement fail!, errCode:%d", errCode); - return errCode; + LOGE("[DeleteSyncDataItem] Get statement fail!"); + return -E_INVALID_QUERY_FORMAT; } } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp index 85714b270..92e7386bb 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp @@ -241,19 +241,6 @@ int SQLiteSingleVerStorageEngine::MigrateSyncData(SQLiteSingleVerStorageExecutor LOGD("Begin migrate sync data, need migrate version[%llu]", GetCacheRecordVersion() - 1); uint64_t curMigrateVer = 0; // The migration process is asynchronous and continuous NotifyMigrateSyncData syncData; - auto kvdbManager = KvDBManager::GetInstance(); - if (kvdbManager != nullptr) { - auto identifier = GetIdentifier(); - auto kvdb = kvdbManager->FindKvDB(identifier); - if (kvdb != nullptr) { - auto kvStore = static_cast(kvdb); - syncData.isPermitForceWrite = - !(kvStore->GetDbProperties().GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false)); - RefObject::DecObjRef(kvdb); - } else { - LOGE("[SingleVerEngine] kvdb is null."); - } - } // cache atomic version represents version of cacheDb input next time while (curMigrateVer < GetCacheRecordVersion()) { errCode = MigrateSyncDataByVersion(handle, syncData, curMigrateVer); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp index 07257fcf1..ae9970dd0 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp @@ -141,8 +141,10 @@ int SQLiteSingleVerStorageExecutor::GetKvData(SingleVerDataType type, const Key // get timestamp if (type == SingleVerDataType::LOCAL_TYPE) { timeStamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_LOCAL_TIME_INDEX)); + LOGD("[SingleVerExe][GetKv] Timestamp from local is %llu", timeStamp); } else if (type == SingleVerDataType::SYNC_TYPE) { timeStamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_SYNC_TIME_INDEX)); + LOGD("[SingleVerExe][GetKv] Timestamp from sync is %llu", timeStamp); } END: @@ -416,6 +418,7 @@ void SQLiteSingleVerStorageExecutor::InitCurrentMaxStamp(TimeStamp &maxStamp) errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { maxStamp = static_cast(sqlite3_column_int64(statement, 0)); // get the first column + LOGD("Max time stamp is %llu", maxStamp); } SQLiteUtils::ResetStatement(statement, true, errCode); } @@ -1213,7 +1216,7 @@ int SQLiteSingleVerStorageExecutor::SaveSyncDataToDatabase(const DataItem &dataI } DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataItem, - const DataItem &itemGet, const std::string &devName, bool isHashKeyExisted, bool isPermitForceWrite) + const DataItem &itemGet, const std::string &devName, bool isHashKeyExisted) { DataOperStatus status; status.isDeleted = ((dataItem.flag & DataItem::DELETE_FLAG) == DataItem::DELETE_FLAG || @@ -1226,8 +1229,7 @@ DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataI } std::string deviceName = DBCommon::TransferHashString(devName); if (itemGet.writeTimeStamp >= dataItem.writeTimeStamp) { - // for multi user mode, no permit to forcewrite - if ((!deviceName.empty()) && (itemGet.dev == deviceName) && isPermitForceWrite) { + if ((!deviceName.empty()) && (itemGet.dev == deviceName)) { LOGI("Force overwrite the data:%llu vs %llu", itemGet.writeTimeStamp, dataItem.writeTimeStamp); status.isDefeated = false; dataItem.writeTimeStamp = itemGet.writeTimeStamp + 1; @@ -1280,7 +1282,7 @@ namespace { } int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem &dataItem, - const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify, bool isPermitForceWrite) + const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify) { // Check sava data existed info int errCode = GetSyncDataItemPre(dataItem, notify.getData, notify.hashKey); @@ -1303,8 +1305,7 @@ int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem return ResetSaveSyncStatements(-E_IGNORE_DATA); } - notify.dataStatus = JudgeSyncSaveType(dataItem, notify.getData, deviceInfo.deviceName, isHashKeyExisted, - isPermitForceWrite); + notify.dataStatus = JudgeSyncSaveType(dataItem, notify.getData, deviceInfo.deviceName, isHashKeyExisted); InitCommitNotifyDataKeyStatus(notify.committedData, notify.hashKey, notify.dataStatus); // Nonexistent data, but deleted by local. @@ -1336,13 +1337,13 @@ int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem } int SQLiteSingleVerStorageExecutor::SaveSyncDataItem(DataItem &dataItem, const DeviceInfo &deviceInfo, - TimeStamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData, bool isPermitForceWrite) + TimeStamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData) { NotifyConflictAndObserverData notify = { .committedData = committedData }; - int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify, isPermitForceWrite); + int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify); if (errCode != E_OK) { if (errCode == -E_IGNORE_DATA) { errCode = E_OK; @@ -2159,6 +2160,7 @@ uint64_t SQLiteSingleVerStorageExecutor::GetLogFileSize() const if (result != E_OK) { return 0; } + LOGI("The log file size is %llu", fileSize); return fileSize; } } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp index 0c2d44754..9559b8fb4 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp @@ -265,8 +265,7 @@ int SQLiteSingleVerStorageExecutor::MigrateDataItem(DataItem &dataItem, NotifyMi // Put or delete. Prepare notify data here. NotifyConflictAndObserverData notify; notify.committedData = syncData.committedData; - int errCode = PutIntoConflictAndCommitForMigrateCache(dataItem, {dataItem.dev.empty(), dataItem.dev}, notify, - syncData.isPermitForceWrite); + int errCode = PutIntoConflictAndCommitForMigrateCache(dataItem, {dataItem.dev.empty(), dataItem.dev}, notify); if (errCode != E_OK) { ResetForMigrateCacheData(); LOGE("PutIntoConflictAndCommitForMigrateCache failed, errCode = %d", errCode); @@ -756,9 +755,9 @@ int SQLiteSingleVerStorageExecutor::BindLocalDataInCacheMode(sqlite3_stmt *state } int SQLiteSingleVerStorageExecutor::PutIntoConflictAndCommitForMigrateCache(DataItem &dataItem, - const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify, bool isPermitForceWrite) + const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify) { - int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify, isPermitForceWrite); + int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify); if (errCode != E_OK) { errCode = (errCode == -E_NOT_FOUND ? E_OK : errCode); if (errCode == -E_IGNORE_DATA) { diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp index dd7935f42..60f5911d1 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp @@ -724,41 +724,6 @@ bool CheckFieldName(const std::string &fieldName) } } -int SetFieldInfo(sqlite3_stmt *statement, TableInfo &table) -{ - FieldInfo field; - field.SetColumnId(sqlite3_column_int(statement, 0)); // 0 means column id index - - std::string tmpString; - (void) SQLiteUtils::GetColumnTextValue(statement, 1, tmpString); // 1 means column name index - if (!CheckFieldName(tmpString)) { - LOGE("[AnalysisSchema] unsupported field name."); - return -E_NOT_SUPPORT; - } - field.SetFieldName(tmpString); - - (void) SQLiteUtils::GetColumnTextValue(statement, 2, tmpString); // 2 means datatype index - field.SetDataType(tmpString); - - field.SetNotNull(static_cast(sqlite3_column_int64(statement, 3))); // 3 means whether null index - - (void) SQLiteUtils::GetColumnTextValue(statement, 4, tmpString); // 4 means default value index - if (!tmpString.empty()) { - field.SetDefaultValue(tmpString); - } - - if (sqlite3_column_int64(statement, 5) != 0) { // 5 means primary key index - if (!table.GetPrimaryKey().empty()) { - // Primary key is already set, usually because the primary key has multiple fields, not support - LOGE("[AnalysisSchema] Not support for composite primary key"); - return -E_NOT_SUPPORT; - } - table.SetPrimaryKey(field.GetFieldName()); - } - table.AddField(field); - return E_OK; -} - int AnalysisSchemaFieldDefine(sqlite3 *db, const std::string &tableName, TableInfo &table) { std::string sql = "pragma table_info(" + tableName + ")"; @@ -768,17 +733,39 @@ int AnalysisSchemaFieldDefine(sqlite3 *db, const std::string &tableName, TableIn LOGE("[AnalysisSchema] Prepare the analysis schema field statement error:%d", errCode); return errCode; } - do { errCode = SQLiteUtils::StepWithRetry(statement); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { errCode = E_OK; break; } else if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { - errCode = SetFieldInfo(statement, table); - if (errCode != E_OK) { + FieldInfo field; + std::string tmpString; + + field.SetColumnId(sqlite3_column_int(statement, 0)); // 0 means column id index + + (void) SQLiteUtils::GetColumnTextValue(statement, 1, tmpString); // 1 means column name index + if (!CheckFieldName(tmpString)) { + errCode = -E_NOT_SUPPORT; + LOGE("[AnalysisSchema] unsupported field name."); break; } + field.SetFieldName(tmpString); + + (void) SQLiteUtils::GetColumnTextValue(statement, 2, tmpString); // 2 means datatype index + field.SetDataType(tmpString); + + field.SetNotNull(static_cast(sqlite3_column_int64(statement, 3))); // 3 means whether null index + + (void) SQLiteUtils::GetColumnTextValue(statement, 4, tmpString); // 4 means default value index + if (!tmpString.empty()) { + field.SetDefaultValue(tmpString); + } + + if (sqlite3_column_int64(statement, 5)) { // 5 means primary key index + table.SetPrimaryKey(field.GetFieldName()); + } + table.AddField(field); } else { LOGW("[AnalysisSchema] Step for the analysis schema field failed:%d", errCode); break; @@ -929,6 +916,7 @@ int SQLiteUtils::GetVersion(sqlite3 *db, int &version) if (sqlite3_step(statement) == SQLITE_ROW) { // Get pragma user_version at first column version = sqlite3_column_int(statement, 0); + LOGD("[SqlUtil][GetVer] db version=%d", version); } else { LOGE("[SqlUtil][GetVer] Get db user_version failed."); errCode = SQLiteUtils::MapSQLiteErrno(SQLITE_ERROR); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp index 007a87bf3..a45b782b9 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp @@ -307,7 +307,7 @@ EngineState StorageEngine::GetEngineState() const void StorageEngine::SetEngineState(EngineState state) { - LOGI("Storage engine state to [%d]!", state); + LOGI("Set storage engine state to [%d]!", state); engineState_ = state; } @@ -361,6 +361,7 @@ void StorageEngine::AddStorageExecutor(StorageExecutor *handle) } else { readIdleList_.push_back(handle); } + LOGD("add [%d] storage executor to handle pool.", handle->GetWritable()); } void StorageEngine::CloseExecutor() @@ -411,8 +412,8 @@ StorageExecutor *StorageEngine::FetchStorageExecutor(bool isWrite, std::list SINGLE_VER_STORE_VERSION_CURRENT) { LOGE("[SingleUp][Upgrade] DbVersion=%d is newer.", dbVersion_); return -E_VERSION_NOT_SUPPORT; } - LOGI("[SingleUp][Upgrade] from %d to %d.", dbVersion_, SINGLE_VER_STORE_VERSION_CURRENT); + LOGI("[SingleUp][Upgrade] DbVersion=%d.", dbVersion_); + errCode = BeginUpgrade(); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] Begin error:%d.", errCode); + LOGE("[SingleUp][Upgrade] Begin fail, errCode=%d.", errCode); return errCode; } errCode = ExecuteUpgrade(); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] Execute error:%d.", errCode); + LOGE("[SingleUp][Upgrade] Execute fail, errCode=%d.", errCode); EndUpgrade(false); return errCode; } @@ -46,7 +48,7 @@ int SingleVerDatabaseUpgrader::Upgrade() if (dbVersion_ < SINGLE_VER_STORE_VERSION_CURRENT) { errCode = SetDatabaseVersion(SINGLE_VER_STORE_VERSION_CURRENT); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] SetVersion error:%d.", errCode); + LOGE("[SingleUp][Upgrade] SetVersion fail, errCode=%d.", errCode); EndUpgrade(false); return errCode; } @@ -54,10 +56,11 @@ int SingleVerDatabaseUpgrader::Upgrade() errCode = EndUpgrade(true); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] End error:%d.", errCode); + LOGE("[SingleUp][Upgrade] End fail, errCode=%d.", errCode); return errCode; } + LOGI("[SingleUp][Upgrade] Exit Successfully."); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp index 514a79354..9588a3a24 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp @@ -133,7 +133,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const len += Parcel::GetUInt32Len(); // softwareVersion_ uint32_t schemLen = Parcel::GetStringLen(schema_); if (schemLen == 0) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] schemLen err!"); + LOGE("[AbilitySyncRequestPacket][CalculateLen] schemLen error!"); return 0; } len += schemLen; @@ -145,7 +145,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const // the reason why not 8-byte align is that old version is not 8-byte align // so it is not possible to set 8-byte align for high version. if (len > INT32_MAX) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncRequestPacket][CalculateLen] error length=%llu", len); return 0; } return len; @@ -286,7 +286,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += Parcel::GetIntLen(); uint32_t schemLen = Parcel::GetStringLen(schema_); if (schemLen == 0) { - LOGE("[AbilitySyncAckPacket][CalculateLen] schemLen err!"); + LOGE("[AbilitySyncAckPacket][CalculateLen] schemLen error!"); return 0; } len += schemLen; @@ -299,7 +299,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += DbAbility::CalculateLen(dbAbility_); // dbAbility_ len += SchemaNegotiate::CalculateParcelLen(relationalSyncOpinion_); if (len > INT32_MAX) { - LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncAckPacket][CalculateLen] error length=%llu", len); return 0; } return len; @@ -344,6 +344,7 @@ int AbilitySync::Initialize(ICommunicator *inCommunicator, ISyncInterface *inSto std::shared_ptr &inMetadata, const std::string &deviceId) { if (inCommunicator == nullptr || inStorage == nullptr || deviceId.empty() || inMetadata == nullptr) { + LOGE("[AbilitySync][Initialize] args error"); return -E_INVALID_ARGS; } communicator_ = inCommunicator; @@ -359,16 +360,18 @@ int AbilitySync::SyncStart(uint32_t sessionId, uint32_t sequenceId, uint16_t rem AbilitySyncRequestPacket packet; int errCode = SetAbilityRequestBodyInfo(packet, remoteCommunicatorVersion); if (errCode != E_OK) { + LOGE("[AbilitySync][SyncStart] set AbilityRequestBodyInfo error, errCode=%d", errCode); return errCode; } Message *message = new (std::nothrow) Message(ABILITY_SYNC_MESSAGE); if (message == nullptr) { + LOGE("[AbilitySync][SyncStart] message is nullptr"); return -E_OUT_OF_MEMORY; } message->SetMessageType(TYPE_REQUEST); errCode = message->SetCopiedObject<>(packet); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] SetCopiedObject failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] SetCopiedObject failed, errCode=%d", errCode); delete message; message = nullptr; return errCode; @@ -380,7 +383,7 @@ int AbilitySync::SyncStart(uint32_t sessionId, uint32_t sequenceId, uint16_t rem SetSendConfig(deviceId_, false, SEND_TIME_OUT, conf); errCode = communicator_->SendMessage(deviceId_, message, conf, handler); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] SendPacket failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] SendPacket failed, errCode=%d", errCode); delete message; message = nullptr; } @@ -391,10 +394,12 @@ int AbilitySync::AckRecv(const Message *message, ISyncTaskContext *context) { int errCode = AckMsgCheck(message, context); if (errCode != E_OK) { + LOGE("[AbilitySync][AckRecv] AckMsgCheck error, errCode=%d", errCode); return errCode; } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckRecv] get packet is nullptr"); return -E_INVALID_ARGS; } uint32_t remoteSoftwareVersion = packet->GetSoftwareVersion(); @@ -418,16 +423,18 @@ int AbilitySync::AckRecv(const Message *message, ISyncTaskContext *context) int AbilitySync::RequestRecv(const Message *message, ISyncTaskContext *context) { if (message == nullptr || context == nullptr) { + LOGE("[AbilitySync][RequestRecv] message or context is nullptr"); return -E_INVALID_ARGS; } const AbilitySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestRecv] get packet is nullptr"); return -E_INVALID_ARGS; } if (packet->GetSendCode() == -E_VERSION_NOT_SUPPORT) { AbilitySyncAckPacket ackPacket; (void)SendAck(message, -E_VERSION_NOT_SUPPORT, false, ackPacket); - LOGI("[AbilitySync][RequestRecv] version can not support, remote version is %u", packet->GetProtocolVersion()); + LOGI("[AbilitySync][RequestRecv] version can not support, remote version = %u", packet->GetProtocolVersion()); return -E_VERSION_NOT_SUPPORT; } @@ -444,6 +451,7 @@ int AbilitySync::RequestRecv(const Message *message, ISyncTaskContext *context) int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context) { if (message == nullptr || context == nullptr) { + LOGE("[AbilitySync][AckNotifyRecv] message or context is nullptr"); return -E_INVALID_ARGS; } if (message->GetErrorNo() == E_FEEDBACK_UNKNOWN_MESSAGE) { @@ -453,11 +461,12 @@ int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckNotifyRecv] get packet is nullptr"); return -E_INVALID_ARGS; } int errCode = packet->GetAckCode(); if (errCode != E_OK) { - LOGE("[AbilitySync][AckNotifyRecv] received a errCode %d", errCode); + LOGE("[AbilitySync][AckNotifyRecv] received a errCode=%d", errCode); return errCode; } std::string schema = packet->GetSchema(); @@ -491,22 +500,24 @@ bool AbilitySync::SecLabelCheck(const AbilitySyncRequestPacket *packet) const int32_t remoteSecLabel = packet->GetSecLabel(); int32_t remoteSecFlag = packet->GetSecFlag(); if (remoteSecLabel == NOT_SURPPORT_SEC_CLASSIFICATION || remoteSecLabel == SecurityLabel::NOT_SET) { + LOGI("[AbilitySync][RequestRecv] remoteSecLabel not surpport or not set"); return true; } SecurityOption option; int errCode = (static_cast(storageInterface_))->GetSecurityOption(option); - LOGI("[AbilitySync][RequestRecv] local l:%d, f:%d, errCode:%d", option.securityLabel, option.securityFlag, errCode); + LOGI("[AbilitySync][RequestRecv] local label=%d, flag=%d, errCode=%d", + option.securityLabel, option.securityFlag, errCode); if (errCode == -E_NOT_SUPPORT || option.securityLabel == SecurityLabel::NOT_SET) { return true; } if (remoteSecLabel == FAILED_GET_SEC_CLASSIFICATION || errCode != E_OK) { - LOGE("[AbilitySync][RequestRecv] check error remoteL:%d, errCode:%d", remoteSecLabel, errCode); + LOGE("[AbilitySync][RequestRecv] check error remoteLable=%d, errCode=%d", remoteSecLabel, errCode); return false; } if (remoteSecLabel == option.securityLabel) { return true; } else { - LOGE("[AbilitySync][RequestRecv] check error remote:%d , %d local:%d , %d", + LOGE("[AbilitySync][RequestRecv] check error remote:lable=%d,flag=%d, local:lable=%d,flag=%d", remoteSecLabel, remoteSecFlag, option.securityLabel, option.securityFlag); return false; } @@ -540,6 +551,7 @@ int AbilitySync::HandleVersionV3AckSchemaParam(const AbilitySyncAckPacket *recvP AbilitySyncAckPacket &sendPacket, ISyncTaskContext *context, bool sendOpinion) const { if (IsSingleRelationalVer()) { + LOGI("[AbilitySync][HandleVersionV3AckSchemaParam] Single Relational Ver"); return HandleRelationAckSchemaParam(recvPacket, sendPacket, context, sendOpinion); } HandleKvAckSchemaParam(recvPacket, context, sendPacket); @@ -557,7 +569,7 @@ void AbilitySync::GetPacketSecOption(SecurityOption &option) const LOGE("[AbilitySync][SyncStart] GetSecOpt not surpport sec classification"); option.securityLabel = NOT_SURPPORT_SEC_CLASSIFICATION; } else if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetSecOpt errCode:%d", errCode); + LOGE("[AbilitySync][SyncStart] GetSecOpt errCode=%d", errCode); option.securityLabel = FAILED_GET_SEC_CLASSIFICATION; } } @@ -576,6 +588,7 @@ int AbilitySync::RegisterTransformFunc() uint32_t AbilitySync::CalculateLen(const Message *inMsg) { if ((inMsg == nullptr) || (inMsg->GetMessageId() != ABILITY_SYNC_MESSAGE)) { + LOGE("[AbilitySync][CalculateLen] message is nullptr or messageid not true"); return 0; } int errCode; @@ -584,23 +597,23 @@ uint32_t AbilitySync::CalculateLen(const Message *inMsg) case TYPE_REQUEST: errCode = RequestPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] request packet calc length err %d", errCode); + LOGE("[AbilitySync][CalculateLen] request packet calc length err=%d", errCode); } break; case TYPE_RESPONSE: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] ack packet calc length err %d", errCode); + LOGE("[AbilitySync][CalculateLen] ack packet calc length err=%d", errCode); } break; case TYPE_NOTIFY: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] ack packet calc length err %d", errCode); + LOGE("[AbilitySync][CalculateLen] ack packet calc length err=%d", errCode); } break; default: - LOGE("[AbilitySync][CalculateLen] message type not support, type %d", inMsg->GetMessageType()); + LOGE("[AbilitySync][CalculateLen] message type not support, type=%d", inMsg->GetMessageType()); break; } return len; @@ -609,6 +622,7 @@ uint32_t AbilitySync::CalculateLen(const Message *inMsg) int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("[AbilitySync][Serialization] buffer or message is nullptr"); return -E_INVALID_ARGS; } @@ -620,6 +634,7 @@ int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message * case TYPE_NOTIFY: return AckPacketSerialization(buffer, length, inMsg); default: + LOGE("[AbilitySync][Serialization] message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -627,6 +642,7 @@ int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message * int AbilitySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("[AbilitySync][DeSerialization] buffer or message is nullptr"); return -E_INVALID_ARGS; } @@ -638,6 +654,7 @@ int AbilitySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message case TYPE_NOTIFY: return AckPacketDeSerialization(buffer, length, inMsg); default: + LOGE("[AbilitySync][DeSerialization] message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -646,6 +663,7 @@ int AbilitySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { const AbilitySyncRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestPacketCalculateLen] get packet is nullptr"); return -E_INVALID_ARGS; } @@ -657,6 +675,7 @@ int AbilitySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { const AbilitySyncAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckPacketCalculateLen] get packet is nullptr"); return -E_INVALID_ARGS; } @@ -668,6 +687,7 @@ int AbilitySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, co { const AbilitySyncRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("[AbilitySync][RequestPacketSerialization]get packet is nullptr or length error"); return -E_INVALID_ARGS; } @@ -682,6 +702,7 @@ int AbilitySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, co parcel.WriteUInt64(packet->GetDbCreateTime()); int errCode = DbAbility::Serialize(parcel, packet->GetDbAbility()); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][RequestPacketSerialization] Serialize error errCode=%d", errCode); return -E_PARSE_FAIL; } return E_OK; @@ -691,6 +712,7 @@ int AbilitySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const { const AbilitySyncAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("[AbilitySync][AckPacketSerialization] get packet is nullptr or length error"); return -E_INVALID_ARGS; } @@ -707,10 +729,12 @@ int AbilitySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const parcel.WriteUInt64(packet->GetDbCreateTime()); int errCode = DbAbility::Serialize(parcel, packet->GetDbAbility()); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][AckPacketSerialization] Serialize error errCode=%d", errCode); return -E_PARSE_FAIL; } errCode = SchemaNegotiate::SerializeData(packet->GetRelationalSyncOpinion(), parcel); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][AckPacketSerialization] SerializeData error errCode=%d", errCode); return -E_PARSE_FAIL; } return E_OK; @@ -720,6 +744,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le { auto *packet = new (std::nothrow) AbilitySyncRequestPacket(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestPacketDeSerialization] get packet is nullptr"); return -E_OUT_OF_MEMORY; } @@ -732,6 +757,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le parcel.ReadUInt32(version); if (parcel.IsError()) { + LOGE("[AbilitySync][RequestPacketDeSerialization] parcel is error"); goto ERROR_OUT; } packet->SetProtocolVersion(version); @@ -739,6 +765,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le packet->SetSendCode(-E_VERSION_NOT_SUPPORT); errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("[AbilitySync][RequestPacketDeSerialization] SetExternalObject error errCode=%d", errCode); goto ERROR_OUT; } return errCode; @@ -748,6 +775,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le parcel.ReadString(schema); errCode = RequestPacketDeSerializationTailPart(parcel, packet, softwareVersion); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][RequestPacketDeSerialization] RequestPacketDeSerializationTailPart error errCode=%d", errCode); goto ERROR_OUT; } packet->SetSendCode(sendCode); @@ -787,7 +815,7 @@ int AbilitySync::RequestPacketDeSerializationTailPart(Parcel &parcel, AbilitySyn DbAbility remoteDbAbility; int errCode = DbAbility::DeSerialize(parcel, remoteDbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync] request packet DeSerializ failed."); + LOGE("[AbilitySync] request packet DeSerializ failed, errCode=%d", errCode); return errCode; } packet->SetDbAbility(remoteDbAbility); @@ -821,14 +849,14 @@ int AbilitySync::AckPacketDeSerializationTailPart(Parcel &parcel, AbilitySyncAck DbAbility remoteDbAbility; int errCode = DbAbility::DeSerialize(parcel, remoteDbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync] ack packet DeSerializ failed."); + LOGE("[AbilitySync] ack packet DeSerializ failed, errCode=%d", errCode); return errCode; } packet->SetDbAbility(remoteDbAbility); RelationalSyncOpinion relationalSyncOpinion; errCode = SchemaNegotiate::DeserializeData(parcel, relationalSyncOpinion); if (errCode != E_OK) { - LOGE("[AbilitySync] ack packet DeSerializ RelationalSyncOpinion failed."); + LOGE("[AbilitySync] ack packet DeSerializ RelationalSyncOpinion failed, errCode=%d", errCode); return errCode; } packet->SetRelationalSyncOpinion(relationalSyncOpinion); @@ -839,6 +867,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length { auto *packet = new (std::nothrow) AbilitySyncAckPacket(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestDeSerialization] get packet is nullptr"); return -E_OUT_OF_MEMORY; } @@ -859,6 +888,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length packet->SetAckCode(-E_VERSION_NOT_SUPPORT); errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("[AckPacketDeSerialization] ack packet SetExternalObject failed, errCode=%d", errCode); goto ERROR_OUT; } return errCode; @@ -868,7 +898,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length parcel.ReadString(schema); errCode = AckPacketDeSerializationTailPart(parcel, packet, softwareVersion); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][RequestDeSerialization] DeSerialization failed!"); + LOGE("[AbilitySync][RequestDeSerialization] DeSerialization failed, errCode=%d", errCode); errCode = -E_PARSE_FAIL; goto ERROR_OUT; } @@ -892,7 +922,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin int errCode = (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDatabaseCreateTimeStamp failed, err %d", errCode); + LOGE("[AbilitySync][SetAbilityRequestBodyInfo] GetDatabaseCreateTimeStamp failed, err=%d", errCode); return errCode; } SecurityOption option; @@ -911,7 +941,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin DbAbility dbAbility; errCode = GetDbAbilityInfo(dbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDbAbility failed, err %d", errCode); + LOGE("[AbilitySync][SetAbilityRequestBodyInfo] GetDbAbility failed, err=%d", errCode); return errCode; } // 102 version is forbidden to sync with 103 json-schema or flatbuffer-schema @@ -948,13 +978,13 @@ int AbilitySync::SetAbilityAckBodyInfo(AbilitySyncAckPacket &ackPacket, int ackC errCode = (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err=%d", errCode); ackCode = errCode; } DbAbility dbAbility; errCode = GetDbAbilityInfo(dbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDbAbility failed, err %d", errCode); + LOGE("[AbilitySync][SetAbilityAckBodyInfo] GetDbAbility failed, err=%d", errCode); return errCode; } ackPacket.SetDbCreateTime(dbCreateTime); @@ -982,6 +1012,7 @@ int AbilitySync::GetDbAbilityInfo(DbAbility &dbAbility) const for (const auto &item : SyncConfig::ABILITYBITS) { errCode = dbAbility.SetAbilityItem(item, SUPPORT_MARK); if (errCode != E_OK) { + LOGE("[AbilitySync][GetDbAbilityInfo] SetAbilityItem failed, err=%d", errCode); return errCode; } } @@ -991,6 +1022,7 @@ int AbilitySync::GetDbAbilityInfo(DbAbility &dbAbility) const int AbilitySync::AckMsgCheck(const Message *message, ISyncTaskContext *context) const { if (message == nullptr || context == nullptr) { + LOGE("[AbilitySync][AckMsgCheck] message or context is nullptr"); return -E_INVALID_ARGS; } if (message->GetErrorNo() == E_FEEDBACK_UNKNOWN_MESSAGE) { @@ -1006,11 +1038,12 @@ int AbilitySync::AckMsgCheck(const Message *message, ISyncTaskContext *context) } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckMsgCheck] packet is nullptr"); return -E_INVALID_ARGS; } int ackCode = packet->GetAckCode(); if (ackCode != E_OK) { - LOGE("[AbilitySync][AckMsgCheck] received an errCode %d", ackCode); + LOGE("[AbilitySync][AckMsgCheck] received an errCode=%d", ackCode); context->SetTaskErrCode(ackCode); return ackCode; } @@ -1034,6 +1067,7 @@ int AbilitySync::HandleRequestRecv(const Message *message, ISyncTaskContext *con { const AbilitySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][HandleRequestRecv] packet is nullptr"); return -E_INVALID_ARGS; } uint32_t remoteSoftwareVersion = packet->GetSoftwareVersion(); @@ -1068,6 +1102,7 @@ int AbilitySync::SendAck(const Message *message, int ackCode, bool isAckNotify, { int errCode = SetAbilityAckBodyInfo(ackPacket, ackCode, isAckNotify); if (errCode != E_OK) { + LOGE("[AbilitySync][SendAck] SetAbilityAckBodyInfo error errCode=%d", errCode); return errCode; } if (IsSingleRelationalVer()) { @@ -1086,6 +1121,7 @@ int AbilitySync::SendAckWithEmptySchema(const Message *message, int ackCode, AbilitySyncAckPacket ackPacket; int errCode = SetAbilityAckBodyInfo(ackPacket, ackCode, isAckNotify); if (errCode != E_OK) { + LOGE("[AbilitySync][SendAckWithEmptySchema] SetAbilityAckBodyInfo error errCode=%d", errCode); return errCode; } SetAbilityAckSchemaInfo(ackPacket, SchemaObject()); @@ -1101,7 +1137,7 @@ int AbilitySync::SendAck(const Message *inMsg, const AbilitySyncAckPacket &ackPa } int errCode = ackMessage->SetCopiedObject<>(ackPacket); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SetCopiedObject failed, err %d", errCode); + LOGE("[AbilitySync][SendAck] SetCopiedObject failed, err=%d", errCode); delete ackMessage; ackMessage = nullptr; return errCode; @@ -1114,7 +1150,7 @@ int AbilitySync::SendAck(const Message *inMsg, const AbilitySyncAckPacket &ackPa SetSendConfig(deviceId_, false, SEND_TIME_OUT, conf); errCode = communicator_->SendMessage(deviceId_, ackMessage, conf); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SendPacket failed, err %d", errCode); + LOGE("[AbilitySync][SendAck] SendPacket failed, err=%d", errCode); delete ackMessage; ackMessage = nullptr; } @@ -1192,6 +1228,7 @@ int AbilitySync::AckRecvWithHighVersion(const Message *message, ISyncTaskContext AbilitySyncAckPacket ackPacket; int errCode = HandleVersionV3AckSchemaParam(packet, ackPacket, context, true); if (errCode != E_OK) { + LOGE("[AbilitySync][AckRecvWithHighVersion] HandleVersionV3AckSchemaParam failed,errCode=%d", errCode); return errCode; } auto singleVerContext = static_cast(context); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp index ffb3c0e36..0e2dd38ea 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp @@ -141,6 +141,7 @@ CommitHistorySync::~CommitHistorySync() int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("CommitHistorySync::Serialization buffer is nullptr or error in validity of package."); return -E_MESSAGE_ID_ERROR; } @@ -150,6 +151,7 @@ int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Mes case TYPE_RESPONSE: return AckPacketSerialization(buffer, length, inMsg); default: + LOGE("CommitHistorySync::Serialization message type error."); return -E_MESSAGE_TYPE_ERROR; } } @@ -157,6 +159,7 @@ int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Mes int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("CommitHistorySync::DeSerialization buffer is nullptr or error in validity of package."); return -E_MESSAGE_ID_ERROR; } @@ -166,6 +169,7 @@ int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, M case TYPE_RESPONSE: return AckPacketDeSerialization(buffer, length, inMsg); default: + LOGE("CommitHistorySync::DeSerialization message type error."); return -E_MESSAGE_TYPE_ERROR; } } @@ -173,6 +177,7 @@ int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, M uint32_t CommitHistorySync::CalculateLen(const Message *inMsg) { if (!(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("CommitHistorySync::CalculateLen error in validity of package."); return 0; } @@ -182,12 +187,14 @@ uint32_t CommitHistorySync::CalculateLen(const Message *inMsg) case TYPE_REQUEST: errCode = RequestPacketCalculateLen(inMsg, len); if (errCode != E_OK) { + LOGE("CommitHistorySync::CalculateLen request packet calculateLen error=%d.", errCode); return 0; } return len; case TYPE_RESPONSE: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { + LOGE("CommitHistorySync::CalculateLen ack packet calculateLen error=%d.", errCode); return 0; } return len; @@ -210,6 +217,7 @@ int CommitHistorySync::RegisterTransformFunc() int CommitHistorySync::Initialize(MultiVerKvDBSyncInterface *storagePtr, ICommunicator *communicateHandle) { if ((storagePtr == nullptr) || (communicateHandle == nullptr)) { + LOGE("CommitHistorySync::Initialize storagePtr or communicateHandle is nullptr"); return -E_INVALID_ARGS; } storagePtr_ = storagePtr; @@ -227,6 +235,7 @@ void CommitHistorySync::TimeOutCallback(MultiVerSyncTaskContext *context, const int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) { if (context == nullptr) { + LOGE("CommitHistorySync::SyncStart context is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); @@ -239,6 +248,7 @@ int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_GET_DEVICE_LATEST_COMMIT); } if ((errCode != E_OK) && (errCode != -E_NOT_FOUND)) { + LOGE("CommitHistorySync::SyncStart get device latest commit error=%d.", errCode); return errCode; } @@ -249,16 +259,18 @@ int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) int CommitHistorySync::RequestRecvCallback(const MultiVerSyncTaskContext *context, const Message *message) { if (!IsPacketValid(message, TYPE_REQUEST) || context == nullptr) { + LOGE("CommitHistorySync::RequestRecvCallback error in validity of package or context is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::RequestRecvCallback packet is nullptr."); return -E_INVALID_ARGS; } std::vector commits; int errCode = RunPermissionCheck(context->GetDeviceId()); if (errCode == -E_NOT_PERMIT) { - LOGE("CommitHistorySync::RequestRecvCallback RunPermissionCheck not pass"); + LOGE("CommitHistorySync::RequestRecvCallback RunPermissionCheck not pass error=%d", errCode); SendAckPacket(context, commits, errCode, message); return errCode; } @@ -292,6 +304,7 @@ int CommitHistorySync::RequestRecvCallback(const MultiVerSyncTaskContext *contex int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const Message *message) { if (!IsPacketValid(message, TYPE_RESPONSE) || (context == nullptr)) { + LOGE("CommitHistorySync::AckRecvCallback error in validity of package or context is nullptr."); return -E_INVALID_ARGS; } @@ -300,6 +313,7 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M const CommitHistorySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::AckRecvCallback packet is nullptr."); return -E_INVALID_ARGS; } packet->GetErrorCode(errCode); @@ -320,14 +334,17 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M int CommitHistorySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (inMsg == nullptr) { + LOGE("CommitHistorySync::RequestPacketCalculateLen inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::RequestPacketCalculateLen packet is nullptr."); return -E_INVALID_ARGS; } if ((inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE) || (inMsg->GetMessageType() != TYPE_REQUEST)) { + LOGE("CommitHistorySync::RequestPacketCalculateLen get message error."); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -337,10 +354,12 @@ int CommitHistorySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("CommitHistorySync::RequestPacketSerialization buffer or inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("CommitHistorySync::RequestPacketSerialization packet is nullptr or packet length error."); return -E_INVALID_ARGS; } @@ -350,25 +369,31 @@ int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t leng int errCode = parcel.WriteUInt64(commitMap.size()); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write size error=%d.", errCode); return -E_SECUREC_ERROR; } // commitMap Serialization for (auto &iter : commitMap) { errCode = parcel.WriteString(iter.first); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write item error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteMultiVerCommit(iter.second); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write" + " multivercommit error:%d.", errCode); return -E_SECUREC_ERROR; } } errCode = parcel.WriteUInt32(packet->GetVersion()); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write version error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteVector(packet->GetReserved()); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel get reserved error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -378,6 +403,7 @@ int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t leng int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("CommitHistorySync::RequestPacketDeSerialization buffer or inMsg is nullptr"); return -E_INVALID_ARGS; } @@ -399,6 +425,7 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 commitMap[key] = val; len--; if (parcel.IsError()) { + LOGE("CommitHistorySync::RequestPacketDeSerialization parcel error."); return -E_INVALID_ARGS; } } @@ -422,6 +449,7 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 packet->SetReserved(reserved); int errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketDeSerialization packet set external object error=%d", errCode); delete packet; packet = nullptr; } @@ -431,14 +459,17 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 int CommitHistorySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (inMsg == nullptr) { + LOGE("CommitHistorySync::AckPacketCalculateLen inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::AckPacketCalculateLen packet is nullptr."); return -E_INVALID_ARGS; } if ((inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE) || (inMsg->GetMessageType() != TYPE_RESPONSE)) { + LOGE("CommitHistorySync::AckPacketCalculateLen get message error."); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -448,10 +479,12 @@ int CommitHistorySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("CommitHistorySync::AckPacketSerialization buffer or inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("CommitHistorySync::AckPacketSerialization packet is nullptr or lengeh error."); return -E_INVALID_ARGS; } @@ -464,10 +497,12 @@ int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, // errCode Serialization int errCode = parcel.WriteInt(ackErrCode); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel write ErrCode error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteUInt32(packet->GetVersion()); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel write version error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -475,10 +510,12 @@ int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, // commits vector Serialization errCode = parcel.WriteMultiVerCommits(commits); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel write MultiVerCommits error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteVector(packet->GetReserved()); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel get reserved error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -519,6 +556,7 @@ int CommitHistorySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t packet->SetReserved(reserved); int errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketDeSerialization set external object error=%d.", errCode); delete packet; packet = nullptr; } @@ -531,6 +569,7 @@ bool CommitHistorySync::IsPacketValid(const Message *inMsg, uint16_t messageType return false; } if (messageType != inMsg->GetMessageType()) { + LOGE("CommitHistorySync::IsPacketValid messageType error."); return false; } return true; @@ -538,7 +577,7 @@ bool CommitHistorySync::IsPacketValid(const Message *inMsg, uint16_t messageType int CommitHistorySync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("CommitHistorySync::Send ERR! err = %d", errCode); @@ -551,6 +590,7 @@ int CommitHistorySync::GetDeviceLatestCommit(std::map readCommitMap; int errCode = storagePtr_->GetDeviceLatestCommit(readCommitMap); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetDeviceLatestCommit get device latest commit ERR! err = %d", errCode); return errCode; } @@ -564,6 +604,7 @@ int CommitHistorySync::GetDeviceLatestCommit(std::mapTransferSyncCommitDevInfo(item.second, localDevice, false); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetDeviceLatestCommit transfer synccommit devInfo ERR! err = %d", errCode); break; } commitMap.insert(std::make_pair(item.second.deviceInfo, item.second)); @@ -579,7 +620,7 @@ int CommitHistorySync::GetCommitTree(const std::mapTransferSyncCommitDevInfo(commitNode, localDevice, true); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetCommitTree commitNode TransferSyncCommitDevInfo error = %d", errCode); return errCode; } newCommitMap.insert(std::make_pair(commitNode.deviceInfo, commitNode)); @@ -595,11 +637,13 @@ int CommitHistorySync::GetCommitTree(const std::mapGetCommitTree(newCommitMap, commits); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetCommitTree GetCommitTree error = %d", errCode); return errCode; } for (auto &commit : commits) { errCode = storagePtr_->TransferSyncCommitDevInfo(commit, localDevice, false); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetCommitTree commit TransferSyncCommitDevInfo error = %d", errCode); break; } } @@ -631,7 +675,7 @@ int CommitHistorySync::SendRequestPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete message; message = nullptr; - LOGE("CommitHistorySync::SendRequestPacket : SetExternalObject failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendRequestPacket : SetExternalObject failed errCode=%d", errCode); return errCode; } message->SetSessionId(context->GetRequestSessionId()); @@ -643,7 +687,7 @@ int CommitHistorySync::SendRequestPacket(const MultiVerSyncTaskContext *context, } errCode = Send(message->GetTarget(), message); if (errCode != E_OK) { - LOGE("CommitHistorySync::SendRequestPacket : Send failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendRequestPacket : Send failed errCode=%d", errCode); delete message; message = nullptr; } @@ -681,14 +725,14 @@ int CommitHistorySync::SendAckPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete ackMessage; ackMessage = nullptr; - LOGE("CommitHistorySync::SendAckPacket : SetExternalObject failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendAckPacket : SetExternalObject failed errCode=%d", errCode); return errCode; } ackMessage->SetSequenceId(message->GetSequenceId()); ackMessage->SetSessionId(message->GetSessionId()); errCode = Send(ackMessage->GetTarget(), ackMessage); if (errCode != E_OK) { - LOGE("CommitHistorySync::SendAckPacket : Send failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendAckPacket : Send failed errCode=%d", errCode); delete ackMessage; ackMessage = nullptr; } @@ -708,7 +752,7 @@ int CommitHistorySync::RunPermissionCheck(const std::string &deviceId) const uint8_t flag = CHECK_FLAG_SEND; int errCode = RuntimeContext::GetInstance()->RunPermissionCheck(userId, appId, storeId, deviceId, flag); if (errCode != E_OK) { - LOGE("[CommitHistorySync] RunPermissionCheck not pass errCode:%d, flag:%d", errCode, flag); + LOGE("[CommitHistorySync] RunPermissionCheck not pass errCode=%d, flag=%d", errCode, flag); return -E_NOT_PERMIT; } return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp index 3eef85f24..55f12a119 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp @@ -101,6 +101,7 @@ void CommunicatorProxy::Activate() uint32_t CommunicatorProxy::GetCommunicatorMtuSize() const { if (mainComm_ == nullptr) { + LOGD("[GetCommunicatorMtuSize] mainComm_ is nullptr"); return DBConstant::MIN_MTU_SIZE; } return mainComm_->GetCommunicatorMtuSize(); @@ -132,6 +133,7 @@ uint32_t CommunicatorProxy::GetCommunicatorMtuSize(const std::string &target) co uint32_t CommunicatorProxy::GetTimeout() const { if (mainComm_ == nullptr) { + LOGD("[GetTimeout] mainComm_ is nullptr"); return DBConstant::MIN_TIMEOUT; } return mainComm_->GetTimeout(); @@ -181,6 +183,7 @@ int CommunicatorProxy::GetRemoteCommunicatorVersion(const std::string &target, u } } if (targetCommunicator != nullptr) { + LOGD("[GetRemoteCommunicatorVersion] use equal label to get data"); int errCode = targetCommunicator->GetRemoteCommunicatorVersion(target, outVersion); RefObject::DecObjRef(targetCommunicator); return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp index e8885f87a..74a67fb72 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp @@ -58,6 +58,7 @@ int DeviceManager::Initialize(ICommunicator *communicator, const std::function &offlineCallback) { if (communicator == nullptr) { + LOGE("[Initialize] communicator is nullptr"); return -E_INVALID_ARGS; } RefObject::IncObjRef(communicator); @@ -115,7 +116,7 @@ int DeviceManager::SendBroadCast(uint32_t msgId) if (msgId == LOCAL_DATA_CHANGED) { return SendLocalDataChanged(); } - LOGE("[DeviceManager] invalid BroadCast msgId:%u", msgId); + LOGE("[DeviceManager] invalid BroadCast msgId=%u", msgId); return -E_INVALID_ARGS; } @@ -138,10 +139,10 @@ int DeviceManager::SendLocalDataChanged() } msg->SetMessageId(LOCAL_DATA_CHANGED); msg->SetTarget(deviceId); - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicator_->SendMessage(deviceId, msg, conf); if (errCode != E_OK) { - LOGE("[DeviceManager] SendLocalDataChanged to dev %s{private} failed. err %d", + LOGE("[DeviceManager] SendLocalDataChanged to dev=%s{private} failed. err=%d", deviceId.c_str(), errCode); delete msg; msg = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp index b91f2549f..e691bdb0c 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp @@ -104,6 +104,7 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) } int errCode = CheckSyncActive(syncInterface, isNeedActive); if (errCode != E_OK) { + LOGE("[Syncer] check sync active failed err=%d", errCode); return errCode; } @@ -120,6 +121,7 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) errCode = InitSyncEngine(syncInterface); if (errCode != E_OK) { + LOGE("[Syncer] init sync engine failed err=%d", errCode); return errCode; } syncEngine_->SetEqualIdentifier(); @@ -187,17 +189,19 @@ int GenericSyncer::Sync(const SyncParma ¶m) { int errCode = SyncParamCheck(param); if (errCode != E_OK) { + LOGE("[Syncer] SyncParamCheck failed err=%d", errCode); return errCode; } errCode = AddQueuedManualSyncSize(param.mode, param.wait); if (errCode != E_OK) { + LOGE("[Syncer] AddQueuedManualSyncSize failed err=%d", errCode); return errCode; } uint32_t syncId = GenerateSyncId(); errCode = PrepareSync(param, syncId); if (errCode != E_OK) { - LOGE("[Syncer] PrepareSync failed when sync called, err %d", errCode); + LOGE("[Syncer] PrepareSync failed when sync called, err=%d", errCode); return errCode; } PerformanceAnalysis::GetInstance()->StepTimeRecordEnd(PT_TEST_RECORDS::RECORD_SYNC_TOTAL); @@ -209,6 +213,7 @@ int GenericSyncer::PrepareSync(const SyncParma ¶m, uint32_t syncId) auto *operation = new (std::nothrow) SyncOperation(syncId, param.devices, param.mode, param.onComplete, param.wait); if (operation == nullptr) { + LOGE("[Syncer] operation is nullptr"); SubQueuedSyncSize(); return -E_OUT_OF_MEMORY; } @@ -242,7 +247,7 @@ int GenericSyncer::RemoveSyncOperation(int syncId) std::unique_lock lock(operationMapLock_); auto iter = syncOperationMap_.find(syncId); if (iter != syncOperationMap_.end()) { - LOGD("[Syncer] RemoveSyncOperation id:%d.", syncId); + LOGD("[Syncer] RemoveSyncOperation id=%d.", syncId); operation = iter->second; syncOperationMap_.erase(syncId); lock.unlock(); @@ -275,6 +280,7 @@ int GenericSyncer::StopSync() uint64_t GenericSyncer::GetTimeStamp() { if (timeHelper_ == nullptr) { + LOGD("[Syncer] timeHelper_ is nullptr."); return TimeHelper::GetSysCurrentTime(); } return timeHelper_->GetTime(); @@ -288,6 +294,7 @@ void GenericSyncer::QueryAutoSync(const InternalSyncParma ¶m) void GenericSyncer::AddSyncOperation(SyncOperation *operation) { if (operation == nullptr) { + LOGD("[Syncer] operation is nullptr."); return; } @@ -326,7 +333,7 @@ int GenericSyncer::InitMetaData(ISyncInterface *syncInterface) metadata_ = std::make_shared(); int errCode = metadata_->Initialize(syncInterface); if (errCode != E_OK) { - LOGE("[Syncer] metadata Initializeate failed! err %d.", errCode); + LOGE("[Syncer] metadata Initializeate failed! err=%d.", errCode); metadata_ = nullptr; } return errCode; @@ -341,7 +348,7 @@ int GenericSyncer::InitTimeHelper(ISyncInterface *syncInterface) timeHelper_ = std::make_shared(); int errCode = timeHelper_->Initialize(syncInterface, metadata_); if (errCode != E_OK) { - LOGE("[Syncer] TimeHelper init failed! err:%d.", errCode); + LOGE("[Syncer] TimeHelper init failed! err=%d.", errCode); timeHelper_ = nullptr; } return errCode; @@ -355,6 +362,7 @@ int GenericSyncer::InitSyncEngine(ISyncInterface *syncInterface) } int errCode = BuildSyncEngine(); if (errCode != E_OK) { + LOGE("[Syncer] BuildSyncEngine failed! err=%d.", errCode); return errCode; } const std::function onlineFunc = std::bind(&GenericSyncer::RemoteDataChanged, @@ -370,7 +378,7 @@ int GenericSyncer::InitSyncEngine(ISyncInterface *syncInterface) label_ = syncEngine_->GetLabel(); return E_OK; } else { - LOGE("[Syncer] SyncEngine init failed! err:%d.", errCode); + LOGE("[Syncer] SyncEngine init failed! err=%d.", errCode); if (syncEngine_ != nullptr) { RefObject::KillAndDecObjRef(syncEngine_); syncEngine_ = nullptr; @@ -389,6 +397,7 @@ int GenericSyncer::CheckSyncActive(ISyncInterface *syncInterface, bool isNeedAct LOGI("[Syncer] syncer no need to active"); int errCode = BuildSyncEngine(); if (errCode != E_OK) { + LOGE("[Syncer] BuildSyncEngine failed! err=%d.", errCode); return errCode; } return -E_NO_NEED_ACTIVE; @@ -488,6 +497,7 @@ int GenericSyncer::SyncModuleInit() if (!isInit) { int errCode = SyncResourceInit(); if (errCode != E_OK) { + LOGE("[Syncer] SyncResourceInit failed! err=%d.", errCode); return errCode; } isInit = true; @@ -541,33 +551,36 @@ int GenericSyncer::SyncResourceInit() int GenericSyncer::GetQueuedSyncSize(int *queuedSyncSize) const { if (queuedSyncSize == nullptr) { + LOGE("[GenericSyncer] queuedSyncSize is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); *queuedSyncSize = queuedManualSyncSize_; - LOGI("[GenericSyncer] GetQueuedSyncSize:%d", queuedManualSyncSize_); + LOGI("[GenericSyncer] GetQueuedSyncSize=%d", queuedManualSyncSize_); return E_OK; } int GenericSyncer::SetQueuedSyncLimit(const int *queuedSyncLimit) { if (queuedSyncLimit == nullptr) { + LOGE("[GenericSyncer] queuedSyncLimit is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); queuedManualSyncLimit_ = *queuedSyncLimit; - LOGI("[GenericSyncer] SetQueuedSyncLimit:%d", queuedManualSyncLimit_); + LOGI("[GenericSyncer] SetQueuedSyncLimit=%d", queuedManualSyncLimit_); return E_OK; } int GenericSyncer::GetQueuedSyncLimit(int *queuedSyncLimit) const { if (queuedSyncLimit == nullptr) { + LOGE("[GenericSyncer] queuedSyncLimit is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); *queuedSyncLimit = queuedManualSyncLimit_; - LOGI("[GenericSyncer] GetQueuedSyncLimit:%d", queuedManualSyncLimit_); + LOGI("[GenericSyncer] GetQueuedSyncLimit=%d", queuedManualSyncLimit_); return E_OK; } @@ -598,15 +611,15 @@ bool GenericSyncer::IsQueuedManualSyncFull(int mode, bool wait) const { std::lock_guard lock(queuedManualSyncLock_); if (IsManualSync(mode) && (!manualSyncEnable_)) { - LOGI("[GenericSyncer] manualSyncEnable_:false"); + LOGI("[GenericSyncer] manualSyncEnable_=false"); return true; } if (IsManualSync(mode) && (!wait)) { if (queuedManualSyncSize_ < queuedManualSyncLimit_) { + LOGD("[GenericSyncer] queuedManualSyncSize_=%d < queuedManualSyncLimit_=%d", queuedManualSyncSize_, + queuedManualSyncLimit_); return false; } else { - LOGD("[GenericSyncer] queuedManualSyncSize_:%d < queuedManualSyncLimit_:%d", queuedManualSyncSize_, - queuedManualSyncLimit_); return true; } } else { @@ -628,7 +641,7 @@ int GenericSyncer::DisableManualSync(void) { std::lock_guard lock(queuedManualSyncLock_); if (queuedManualSyncSize_ > 0) { - LOGD("[GenericSyncer] DisableManualSync fail, queuedManualSyncSize_:%d", queuedManualSyncSize_); + LOGD("[GenericSyncer] DisableManualSync fail, queuedManualSyncSize_=%d", queuedManualSyncSize_); return -E_BUSY; } manualSyncEnable_ = false; @@ -649,7 +662,7 @@ int GenericSyncer::GetLocalIdentity(std::string &outTarget) const std::string deviceId; int errCode = RuntimeContext::GetInstance()->GetLocalIdentity(deviceId); if (errCode != E_OK) { - LOGE("[GenericSyncer] GetLocalIdentity fail errCode:%d", errCode); + LOGE("[GenericSyncer] GetLocalIdentity fail errCode=%d", errCode); return errCode; } outTarget = DBCommon::TransferHashString(deviceId); @@ -688,6 +701,7 @@ void GenericSyncer::GetOnlineDevices(std::vector &devices) const int GenericSyncer::SetSyncRetry(bool isRetry) { if (syncEngine_ == nullptr) { + LOGE("[Syncer] syncEngine_ is nullptr"); return -E_NOT_INIT; } syncEngine_->SetSyncRetry(isRetry); @@ -698,6 +712,7 @@ int GenericSyncer::SetEqualIdentifier(const std::string &identifier, const std:: { std::lock_guard lock(syncerLock_); if (syncEngine_ == nullptr) { + LOGE("[Syncer] syncEngine_ is nullptr"); return -E_NOT_INIT; } int errCode = syncEngine_->SetEqualIdentifier(identifier, targets); @@ -735,9 +750,11 @@ int GenericSyncer::SyncParamCheck(const SyncParma ¶m) const std::lock_guard lock(syncerLock_); int errCode = StatusCheck(); if (errCode != E_OK) { + LOGE("[Syncer] StatusCheck failed err=%d", errCode); return errCode; } if (!IsValidDevices(param.devices) || !IsValidMode(param.mode)) { + LOGE("[Syncer] Validity error"); return -E_INVALID_ARGS; } if (IsQueuedManualSyncFull(param.mode, param.wait)) { @@ -768,6 +785,7 @@ int GenericSyncer::BuildSyncEngine() } syncEngine_ = CreateSyncEngine(); if (syncEngine_ == nullptr) { + LOGE("[Syncer] syncEngine_ is nullptr"); return -E_OUT_OF_MEMORY; } syncEngine_->OnLastRef([this]() { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 2ab367bb6..7a9efb790 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -54,9 +54,11 @@ int Metadata::Initialize(ISyncInterface* storage) int errCode = GetMetadataFromDb(key, timeOffset); if (errCode == -E_NOT_FOUND) { - int err = SaveLocalTimeOffset(TimeHelper::BASE_OFFSET); + LOGD("[Metadata][Initialize] GetMetadataFromDb failed errCode=%d", errCode); + uint64_t randTimeOffset = GetRandTimeOffset(); + int err = SaveLocalTimeOffset(TimeHelper::BASE_OFFSET + static_cast(randTimeOffset)); if (err != E_OK) { - LOGD("[Metadata][Initialize]SaveLocalTimeOffset failed errCode:%d", err); + LOGD("[Metadata][Initialize]SaveLocalTimeOffset failed errCode=%d", err); return err; } } else if (errCode == E_OK) { @@ -80,7 +82,7 @@ int Metadata::SaveTimeOffset(const DeviceID &deviceId, TimeOffset inValue) GetMetaDataValue(deviceId, metadata, true); metadata.timeOffset = inValue; metadata.lastUpdateTime = TimeHelper::GetSysCurrentTime(); - LOGD("Metadata::SaveTimeOffset = %lld dev %s", inValue, STR_MASK(deviceId)); + LOGD("Metadata::SaveTimeOffset = %lld dev=%s", inValue, STR_MASK(deviceId)); return SaveMetaDataValue(deviceId, metadata); } @@ -140,7 +142,7 @@ int Metadata::SaveLocalTimeOffset(TimeOffset timeOffset) LOGD("Metadata::SaveLocalTimeOffset offset = %lld", timeOffset); int errCode = SetMetadataToDb(localTimeOffsetValue, timeOffsetValue); if (errCode != E_OK) { - LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode:%d", errCode); + LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode=%d", errCode); } return errCode; } @@ -167,15 +169,15 @@ int Metadata::EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, // peerWaterMark must be erased at last int errCode = SavePeerWaterMark(deviceId, 0, isNeedHash); if (errCode != E_OK) { - LOGE("[Metadata] erase peerWaterMark failed errCode:%d", errCode); + LOGE("[Metadata] erase peerWaterMark failed errCode=%d", errCode); return errCode; } if (errCodeQuerySync != E_OK) { - LOGE("[Metadata] erase queryWaterMark failed errCode:%d", errCodeQuerySync); + LOGE("[Metadata] erase queryWaterMark failed errCode=%d", errCodeQuerySync); return errCodeQuerySync; } if (errCodeDeleteSync != E_OK) { - LOGE("[Metadata] erase deleteWaterMark failed errCode:%d", errCodeDeleteSync); + LOGE("[Metadata] erase deleteWaterMark failed errCode=%d", errCodeDeleteSync); return errCodeDeleteSync; } return E_OK; @@ -200,6 +202,7 @@ int Metadata::SaveMetaDataValue(const DeviceID &deviceId, const MetaDataValue &i std::vector value; int errCode = SerializeMetaData(inValue, value); if (errCode != E_OK) { + LOGE("Metadata::SaveMetaDataValue SerializeMetaData failed errCode=%d", errCode); return errCode; } @@ -209,7 +212,7 @@ int Metadata::SaveMetaDataValue(const DeviceID &deviceId, const MetaDataValue &i DBCommon::StringToVector(hashDeviceId, key); errCode = SetMetadataToDb(key, value); if (errCode != E_OK) { - LOGE("Metadata::SetMetadataToDb failed errCode:%d", errCode); + LOGE("Metadata::SetMetadataToDb failed errCode=%d", errCode); return errCode; } PutMetadataToMap(hashDeviceId, inValue); @@ -249,6 +252,7 @@ int Metadata::DeSerializeMetaData(const std::vector &inValue, MetaDataV int Metadata::GetMetadataFromDb(const std::vector &key, std::vector &outValue) const { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::GetMetadataFromDb naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->GetMetaData(key, outValue); @@ -257,6 +261,7 @@ int Metadata::GetMetadataFromDb(const std::vector &key, std::vector &key, const std::vector &inValue) { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::SetMetadataToDb naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->PutMetaData(key, inValue); @@ -265,6 +270,7 @@ int Metadata::SetMetadataToDb(const std::vector &key, const std::vector int Metadata::DeleteMetaDataFromDB(const std::vector &keys) const { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::DeleteMetaDataFromDB naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->DeleteMetaData(keys); @@ -291,6 +297,7 @@ int64_t Metadata::StringToLong(const std::vector &value) const int Metadata::GetAllMetadataKey(std::vector> &keys) { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::GetAllMetadataKey naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->GetAllMetaKeys(keys); @@ -322,15 +329,17 @@ int Metadata::LoadAllMetadata() std::vector> querySyncIds; for (const auto &deviceId : metaDataKeys) { if (IsMetaDataKey(deviceId, DEVICEID_PREFIX_KEY)) { - errCode = LoadDeviceIdDataToMap(deviceId); + int errCode = LoadDeviceIdDataToMap(deviceId); if (errCode != E_OK) { + LOGE("[Metadata] LoadDeviceIdDataToMap failed err=%d", errCode); return errCode; } } else if (IsMetaDataKey(deviceId, QuerySyncWaterMarkHelper::GetQuerySyncPrefixKey())) { querySyncIds.push_back(deviceId); } else if (IsMetaDataKey(deviceId, QuerySyncWaterMarkHelper::GetDeleteSyncPrefixKey())) { - errCode = querySyncWaterMarkHelper_.LoadDeleteSyncDataToCache(deviceId); + int errCode = querySyncWaterMarkHelper_.LoadDeleteSyncDataToCache(deviceId); if (errCode != E_OK) { + LOGE("[Metadata] LoadDeleteSyncDataToCache failed err=%d", errCode); return errCode; } } @@ -343,12 +352,14 @@ int Metadata::LoadDeviceIdDataToMap(const Key &key) std::vector value; int errCode = GetMetadataFromDb(key, value); if (errCode != E_OK) { + LOGE("Metadata::LoadDeviceIdDataToMap GetMetadataFromDb failed err=%d", errCode); return errCode; } MetaDataValue metaValue; std::string metaKey(key.begin(), key.end()); errCode = DeSerializeMetaData(value, metaValue); if (errCode != E_OK) { + LOGE("Metadata::LoadDeviceIdDataToMap DeSerializeMetaData failed err=%d", errCode); return errCode; } std::lock_guard lockGuard(metadataLock_); @@ -389,6 +400,7 @@ int Metadata::GetRecvQueryWaterMark(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetRecvQueryWaterMark GetQueryWaterMark failed err=%d", errCode); return errCode; } WaterMark peerWaterMark; @@ -409,6 +421,7 @@ int Metadata::GetSendQueryWaterMark(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetSendQueryWaterMark GetQueryWaterMark failed err=%d", errCode); return errCode; } if (isAutoLift) { @@ -432,6 +445,7 @@ int Metadata::GetLastQueryTime(const std::string &queryIdentify, const std::stri QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetLastQueryTime GetQueryWaterMark failed err=%d", errCode); return errCode; } timeStamp = queryWaterMark.lastQueryTime; @@ -449,6 +463,7 @@ int Metadata::GetSendDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &wa DeleteWaterMark deleteWaterMark; int errCode = querySyncWaterMarkHelper_.GetDeleteSyncWaterMark(deviceId, deleteWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetSendDeleteSyncWaterMark GetDeleteSyncWaterMark failed err=%d", errCode); return errCode; } if (isAutoLift) { @@ -471,6 +486,7 @@ int Metadata::GetRecvDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &wa DeleteWaterMark deleteWaterMark; int errCode = querySyncWaterMarkHelper_.GetDeleteSyncWaterMark(deviceId, deleteWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetRecvDeleteSyncWaterMark GetDeleteSyncWaterMark failed err=%d", errCode); return errCode; } WaterMark peerWaterMark; @@ -538,6 +554,7 @@ int Metadata::ResetMetaDataAfterRemoveData(const DeviceID &deviceId) metadata.localWaterMark = 0; return SaveMetaDataValue(deviceId, metadata); } + LOGI("Metadata::ResetMetaDataAfterRemoveData hashDeviceId not found"); return -E_NOT_FOUND; } @@ -558,6 +575,7 @@ void Metadata::GetRemoveDataMark(const DeviceID &deviceId, uint64_t &outValue) int Metadata::DeleteMetaDataByPrefixKey(const Key &keyPrefix) const { if (naturalStoragePtr_ == nullptr) { + LOGD("Metadata::DeleteMetaDataByPrefixKey naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->DeleteMetaDataByPrefixKey(keyPrefix); @@ -572,6 +590,7 @@ uint64_t Metadata::GetQueryLastTimestamp(const DeviceID &deviceId, const std::st int errCode = GetMetadataFromDb(key, value); std::lock_guard lockGuard(metadataLock_); if (errCode == -E_NOT_FOUND) { + LOGI("errCode is -E_NOT_FOUND"); auto iter = queryIdMap_.find(deviceId); if (iter != queryIdMap_.end()) { if (iter->second.find(hashqueryId) == iter->second.end()) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp index 662c6bb3f..483df48d0 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp @@ -100,6 +100,7 @@ MultiVerDataSync::~MultiVerDataSync() int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("MultiVerDataSync::Serialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -109,6 +110,7 @@ int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Mess case TYPE_RESPONSE: return AckPacketSerialization(buffer, length, inMsg); default: + LOGE("MultiVerDataSync::Serialization message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -116,6 +118,7 @@ int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Mess int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("MultiVerDataSync::DeSerialization buffer is nullptr or packet validity error"); return -E_MESSAGE_ID_ERROR; } @@ -125,6 +128,7 @@ int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Me case TYPE_RESPONSE: return AckPacketDeSerialization(buffer, length, inMsg); default: + LOGE("MultiVerDataSync::DeSerialization message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -132,6 +136,7 @@ int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Me uint32_t MultiVerDataSync::CalculateLen(const Message *inMsg) { if (!(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("MultiVerDataSync::CalculateLen packet validity error"); return 0; } @@ -167,6 +172,7 @@ int MultiVerDataSync::RegisterTransformFunc() int MultiVerDataSync::Initialize(MultiVerKvDBSyncInterface *storagePtr, ICommunicator *communicateHandle) { if ((storagePtr == nullptr) || (communicateHandle == nullptr)) { + LOGE("MultiVerDataSync::Initialize storagePtr or communicateHandle is nullptr"); return -E_INVALID_ARGS; } storagePtr_ = storagePtr; @@ -182,6 +188,7 @@ void MultiVerDataSync::TimeOutCallback(MultiVerSyncTaskContext *context, const M int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) { if (context == nullptr) { + LOGE("MultiVerDataSync::SyncStart context is nullptr"); return -E_INVALID_ARGS; } LOGD("MultiVerDataSync::SyncStart dst=%s{private}, begin", context->GetDeviceId().c_str()); @@ -195,6 +202,7 @@ int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_DATA_GET_VALID_COMMIT); } if (errCode != E_OK) { + LOGI("MultiVerDataSync::SyncStart GetValidCommit failed"); // sync don't need start SendFinishedRequest(context); return errCode; @@ -208,18 +216,22 @@ int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) int MultiVerDataSync::RequestRecvCallback(const MultiVerSyncTaskContext *context, const Message *message) { if (message == nullptr || context == nullptr) { + LOGE("MultiVerDataSync::RequestRecvCallback message or context is nullptr"); return -E_INVALID_ARGS; } if (!IsPacketValid(message, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestRecvCallback packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::RequestRecvCallback packet is nullptr"); return -E_INVALID_ARGS; } if (packet->GetErrCode() == -E_LAST_SYNC_FRAME) { + LOGE("MultiVerDataSync::RequestRecvCallback packet errCode equal -E_LAST_SYNC_FRAME"); return -E_LAST_SYNC_FRAME; } MultiVerCommitNode commit; @@ -250,19 +262,23 @@ int MultiVerDataSync::RequestRecvCallback(const MultiVerSyncTaskContext *context int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Message *message) { if (message == nullptr) { + LOGE("MultiVerDataSync::AckRecvCallback message is nullptr"); return -E_INVALID_ARGS; } if (!IsPacketValid(message, TYPE_RESPONSE) || (context == nullptr)) { + LOGE("MultiVerDataSync::AckRecvCallback context is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::AckRecvCallback packet is nullptr"); return -E_INVALID_ARGS; } int32_t errCode = E_OK; packet->GetErrorCode(errCode); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckRecvCallback packet GetErrorCode=%d", errCode); return errCode; } std::vector> dataEntries; @@ -286,6 +302,7 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me entry = entries[0]; errCode = entry->GetValueHash(valueHashes); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckRecvCallback entry GetValueHash errCode=%d", errCode); return errCode; } } @@ -316,11 +333,12 @@ void MultiVerDataSync::ReleaseKvEntry(const MultiVerKvEntry *entry) void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *context) { if (context == nullptr) { + LOGE("MultiVerDataSync::SendFinishedRequest context is nullptr"); return; } MultiVerRequestPacket *packet = new (std::nothrow) MultiVerRequestPacket(); if (packet == nullptr) { - LOGE("MultiVerRequestPacket::SendRequestPacket : new packet error"); + LOGE("MultiVerRequestPacket::SendFinishedRequest : new packet error"); return; } packet->SetErrCode(-E_LAST_SYNC_FRAME); @@ -328,7 +346,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex if (message == nullptr) { delete packet; packet = nullptr; - LOGE("MultiVerDataSync::SendRequestPacket : new message error"); + LOGE("MultiVerDataSync::SendFinishedRequest : new message error"); return; } message->SetMessageType(TYPE_REQUEST); @@ -339,7 +357,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex packet = nullptr; delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendFinishedRequest] : SetExternalObject failed errCode:%d", errCode); + LOGE("[MultiVerDataSync][SendFinishedRequest] : SetExternalObject failed errCode=%d", errCode); return; } message->SetSessionId(context->GetRequestSessionId()); @@ -349,7 +367,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex if (errCode != E_OK) { delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest failed, err %d", errCode); + LOGE("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest failed, err=%d", errCode); } LOGI("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest dst=%s{private}", context->GetDeviceId().c_str()); } @@ -357,10 +375,12 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex int MultiVerDataSync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { if ((inMsg == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestPacketCalculateLen inMsg is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::RequestPacketCalculateLen packet is nullptr"); return -E_INVALID_ARGS; } @@ -371,10 +391,12 @@ int MultiVerDataSync::RequestPacketCalculateLen(const Message *inMsg, uint32_t & int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestPacketSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("MultiVerDataSync::RequestPacketSerialization packet is nullptr"); return -E_INVALID_ARGS; } @@ -385,6 +407,7 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt Parcel parcel(buffer, length); int errCode = parcel.WriteInt(ackCode); if (errCode != E_OK) { + LOGE("MultiVerDataSync::RequestPacketSerialization parcel write ackCode error=%d", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -392,6 +415,7 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt // commitMap Serialization errCode = parcel.WriteMultiVerCommit(commit); if (errCode != E_OK) { + LOGE("MultiVerDataSync::RequestPacketSerialization parcel write commit error=%d", errCode); return -E_SECUREC_ERROR; } @@ -401,6 +425,7 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestPacketDeSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -409,6 +434,7 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 int32_t pktErrCode; uint64_t packLen = parcel.ReadInt(pktErrCode); if (parcel.IsError()) { + LOGE("MultiVerDataSync::RequestPacketDeSerialization parcel error"); return -E_INVALID_ARGS; } parcel.EightByteAlign(); @@ -416,6 +442,7 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 // commit DeSerialization packLen += parcel.ReadMultiVerCommit(commit); if (packLen != length || parcel.IsError()) { + LOGE("MultiVerDataSync::RequestPacketDeSerialization parcel length=%llu error", packLen); return -E_INVALID_ARGS; } MultiVerRequestPacket *packet = new (std::nothrow) MultiVerRequestPacket(); @@ -436,11 +463,13 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 int MultiVerDataSync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (!IsPacketValid(inMsg, TYPE_RESPONSE)) { + LOGE("MultiVerDataSync::AckPacketCalculateLen packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::AckPacketCalculateLen packet is nullptr"); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -450,10 +479,12 @@ int MultiVerDataSync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_RESPONSE)) { + LOGE("MultiVerDataSync::AckPacketSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("MultiVerDataSync::AckPacketSerialization packet length=%llu error or packet is nullptr", length); return -E_INVALID_ARGS; } @@ -466,6 +497,7 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c // errCode Serialization errCode = parcel.WriteInt(errCode); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckPacketSerialization packet get errorCode=%d", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -474,6 +506,7 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c for (const auto &iter : entries) { errCode = parcel.WriteVectorChar(iter); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckPacketSerialization write entry errorCode=%d", errCode); return -E_SECUREC_ERROR; } } @@ -484,6 +517,7 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_RESPONSE)) { + LOGE("MultiVerDataSync::AckPacketDeSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -493,6 +527,7 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l // errCode DeSerialization uint32_t packLen = parcel.ReadInt(pktErrCode); if (parcel.IsError()) { + LOGE("MultiVerDataSync::AckPacketDeSerialization parcel read error"); return -E_INVALID_ARGS; } parcel.EightByteAlign(); @@ -506,6 +541,7 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l // A valid dataItem got, Save to storage entries.push_back(data); if (parcel.IsError()) { + LOGE("MultiVerDataSync::AckPacketDeSerialization parcel read entry error"); return -E_INVALID_ARGS; } } @@ -527,6 +563,7 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l bool MultiVerDataSync::IsPacketValid(const Message *inMsg, uint16_t messageType) { if ((inMsg == nullptr) || (inMsg->GetMessageId() != MULTI_VER_DATA_SYNC_MESSAGE)) { + LOGE("MultiVerDataSync::AckPacketDeSerialization inMsg is nullptr or get message error"); return false; } if (messageType != inMsg->GetMessageType()) { @@ -576,7 +613,7 @@ bool MultiVerDataSync::IsCommitExisted(const MultiVerCommitNode &commit) int MultiVerDataSync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("MultiVerDataSync::Send ERR! ERR = %d", errCode); @@ -607,7 +644,7 @@ int MultiVerDataSync::SendRequestPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendRequestPacket] : SetExternalObject failed errCode:%d", errCode); + LOGE("[MultiVerDataSync][SendRequestPacket] : SetExternalObject failed errCode=%d", errCode); return errCode; } message->SetSessionId(context->GetRequestSessionId()); @@ -664,7 +701,7 @@ int MultiVerDataSync::SendAckPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete ackMessage; ackMessage = nullptr; - LOGE("[MultiVerDataSync][SendAckPacket] : SetExternalObject failed errCode:%d", errCode); + LOGE("[MultiVerDataSync][SendAckPacket] : SetExternalObject failed errCode=%d", errCode); return errCode; } ackMessage->SetSequenceId(message->GetSequenceId()); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index 8e7fe90a5..af46b4a6c 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -62,10 +62,12 @@ int MultiVerSyncStateMachine::Initialize(ISyncTaskContext *context, ISyncInterfa std::shared_ptr &metadata, ICommunicator *communicator) { if (context == nullptr || syncInterface == nullptr || metadata == nullptr || communicator == nullptr) { + LOGE("MultiVerSyncStateMachine::Initialize args is nullptr"); return -E_INVALID_ARGS; } int errCode = SyncStateMachine::Initialize(context, syncInterface, metadata, communicator); if (errCode != E_OK) { + LOGE("MultiVerSyncStateMachine::Initialize Initialize error=%d", errCode); return errCode; } @@ -76,10 +78,9 @@ int MultiVerSyncStateMachine::Initialize(ISyncTaskContext *context, ISyncInterfa errCode = timeSync_->Initialize(communicator, metadata, syncInterface, context->GetDeviceId()); if (errCode != E_OK) { - LOGE("timeSync_->Initialize failed err %d", errCode); + LOGE("MultiVerSyncStateMachine::Initialize timeSync_->Initialize failed err=%d", errCode); goto ERROR_OUT; } - LOGD("timeSync_->Initialize OK"); // init functions below will never fail multiVerStorage_ = static_cast(syncInterface); @@ -104,7 +105,7 @@ void MultiVerSyncStateMachine::SyncStep() int errCode = RuntimeContext::GetInstance()->ScheduleTask( std::bind(&MultiVerSyncStateMachine::SyncStepInnerLocked, this)); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] Schedule SyncStep failed"); + LOGE("[MultiVerSyncStateMachine] Schedule SyncStep failed errCode=%d", errCode); RefObject::DecObjRef(communicator_); RefObject::DecObjRef(context_); } @@ -123,16 +124,18 @@ int MultiVerSyncStateMachine::MessageCallbackCheck(const Message *inMsg) { RefObject::AutoLock lock(context_); if (context_->IsKilled()) { + LOGE("MultiVerSyncStateMachine::MessageCallbackCheck context is killed"); return -E_OBJ_IS_KILLED; } if (!IsPacketValid(inMsg)) { + LOGE("MultiVerSyncStateMachine::MessageCallbackCheck packet validity error"); return -E_INVALID_ARGS; } if ((inMsg->GetMessageType() == TYPE_RESPONSE) && (inMsg->GetMessageId() != TIME_SYNC_MESSAGE)) { context_->IncSequenceId(); int errCode = ResetWatchDog(); if (errCode != E_OK) { - LOGW("[MultiVerSyncStateMachine][MessageCallback] ResetWatchDog failed , err %d", errCode); + LOGW("[MultiVerSyncStateMachine][MessageCallback] ResetWatchDog failed , err=%d", errCode); } } return E_OK; @@ -141,6 +144,7 @@ int MultiVerSyncStateMachine::MessageCallbackCheck(const Message *inMsg) int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) { if (inMsg == nullptr) { + LOGE("MultiVerSyncStateMachine::ReceiveMessageCallback inMsg is nullptr"); return -E_INVALID_ARGS; } if (inMsg->IsFeedbackError()) { @@ -148,11 +152,13 @@ int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) return -static_cast(inMsg->GetErrorNo()); } if (inMsg->GetMessageId() == TIME_SYNC_MESSAGE) { + LOGD("MultiVerSyncStateMachine::ReceiveMessageCallback messageid is time sync"); return TimeSyncPacketRecvCallback(context_, inMsg); } std::lock_guard lock(stateMachineLock_); int errCode = MessageCallbackCheck(inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine] MessageCallbackCheck error=%d", errCode); return errCode; } switch (inMsg->GetMessageId()) { @@ -173,6 +179,7 @@ int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) break; } if (errCode == -E_LAST_SYNC_FRAME) { + LOGE("[MultiVerSyncStateMachine] errCode is -E_LAST_SYNC_FRAME"); SyncResponseEnd(inMsg->GetSessionId()); return errCode; } @@ -199,7 +206,7 @@ int MultiVerSyncStateMachine::CommitHistorySyncStepInner(void) { int errCode = commitHistorySync_->SyncStart(context_); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][CommitHistorySyncStep] failed, errCode %d", errCode); + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncStep] failed, errCode=%d", errCode); } return errCode; } @@ -243,6 +250,8 @@ void MultiVerSyncStateMachine::SyncStepInnerLocked() if (errCode == -E_NOT_FOUND) { int err = OneCommitSyncFinish(); if (err != E_OK) { + LOGD("[MultiVerSyncStateMachine][SyncStepInnerLocked] OneCommitSyncFinish failed" + ", error=%d", err); valueSliceSync_->SendFinishedRequest(context_); Abort(); goto SYNC_STEP_SAFE_OUT; @@ -279,7 +288,7 @@ int MultiVerSyncStateMachine::StartSyncInner() } int errCode = StartWatchDog(); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][StartSync] WatchDog start failed! err:%d", errCode); + LOGE("[MultiVerSyncStateMachine][StartSync] WatchDog start failed! err=%d", errCode); return errCode; } SyncStep(); @@ -318,6 +327,7 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC { int errCode; if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != TIME_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][TimeSyncPacketRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } switch (inMsg->GetMessageType()) { @@ -327,7 +337,7 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC case TYPE_RESPONSE: errCode = timeSync_->AckRecv(inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] TimeSyncPacketRecvCallback AckRecv failed err %d", errCode); + LOGE("[MultiVerSyncStateMachine] TimeSyncPacketRecvCallback AckRecv failed err=%d", errCode); } return errCode; default: @@ -338,10 +348,12 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; + LOGD("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: if (performance != nullptr) { @@ -354,6 +366,7 @@ int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskC } errCode = commitHistorySync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] AckRecvCallback error=%d", errCode); return errCode; } currentState_ = MULTI_VER_DATA_ENTRY_SYNC; @@ -367,10 +380,12 @@ int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskC int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != MULTI_VER_DATA_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; + LOGD("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: return multiVerDataSync_->RequestRecvCallback(context, inMsg); @@ -380,6 +395,7 @@ int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContex } errCode = multiVerDataSync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] AckRecvCallback error=%d", errCode); multiVerDataSync_->SendFinishedRequest(context); return errCode; } @@ -394,10 +410,12 @@ int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContex int MultiVerSyncStateMachine::ValueSlicePktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != VALUE_SLICE_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; + LOGD("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: return valueSliceSync_->RequestRecvCallback(context, inMsg); @@ -407,6 +425,7 @@ int MultiVerSyncStateMachine::ValueSlicePktRecvCallback(MultiVerSyncTaskContext } errCode = valueSliceSync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] AckRecvCallback error=%d", errCode); valueSliceSync_->SendFinishedRequest(context); return errCode; } @@ -432,7 +451,7 @@ void MultiVerSyncStateMachine::Finish() performance->StepTimeRecordStart(MV_TEST_RECORDS::RECORD_MERGE); } int errCode = multiVerDataSync_->MergeSyncCommit(commit, commits); - LOGD("MultiVerSyncStateMachine::Finish merge src=%s, MergeSyncCommit errCode:%d", + LOGD("MultiVerSyncStateMachine::Finish merge src=%s, MergeSyncCommit errCode=%d", STR_MASK(context_->GetDeviceId()), errCode); if (performance != nullptr) { performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_MERGE); @@ -463,7 +482,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() STR_MASK(context_->GetDeviceId()), entries.size()); errCode = timeSync_->GetTimeOffset(outOffset, TIME_SYNC_WAIT_TIME); if (errCode != E_OK) { - LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset fail errCode:%d", errCode); + LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset failed errCode=%d", errCode); return errCode; } TimeStamp currentLocalTime = context_->GetCurrentLocalTime(); @@ -497,6 +516,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() bool MultiVerSyncStateMachine::IsPacketValid(const Message *inMsg) const { if (inMsg == nullptr) { + LOGE("[MultiVerSyncStateMachine][IsPacketValid] inMsg is nullptr"); return false; } @@ -551,12 +571,12 @@ void MultiVerSyncStateMachine::SyncResponseBegin(uint32_t sessionId) [this]() { int ret = RuntimeContext::GetInstance()->ScheduleTask([this](){ RefObject::DecObjRef(context_); }); if (ret != E_OK) { - LOGE("[MultiVerSyncStateMachine][SyncResponseEnd] timer finalizer ScheduleTask, errCode %d", ret); + LOGE("[MultiVerSyncStateMachine][SyncResponseEnd] timer finalizer ScheduleTask, errCode=%d", ret); } }, timerId); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][ResponseSessionBegin] SetTimer failed err %d", errCode); + LOGE("[MultiVerSyncStateMachine][ResponseSessionBegin] SetTimer failed err=%d", errCode); RefObject::DecObjRef(context_); return; } @@ -575,7 +595,7 @@ void MultiVerSyncStateMachine::SyncResponseEnd(uint32_t sessionId) return info.sessionId == sessionId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseEnd] Can't find sync response %d", sessionId); + LOGW("[MultiVerSyncStateMachine][SyncResponseEnd] Can't find sync response=%d", sessionId); return; } RuntimeContext::GetInstance()->RemoveTimer(iter->timerId); @@ -594,7 +614,7 @@ int MultiVerSyncStateMachine::SyncResponseTimeout(TimerId timerId) return info.timerId == timerId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %d", timerId); + LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId=%d", timerId); return E_OK; } sessionId = iter->sessionId; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp index 96599edac..2a5ed2ce1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp @@ -30,6 +30,7 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf std::shared_ptr &metadata, ICommunicator *communicator) { if (deviceId.empty() || (syncInterface == nullptr) || (communicator == nullptr)) { + LOGE("[MultiVerSyncTaskContext][Initialize] args is nullptr."); return -E_INVALID_ARGS; } syncInterface_ = syncInterface; @@ -40,12 +41,13 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf timeHelper_ = std::make_unique(); int errCode = timeHelper_->Initialize(syncInterface, metadata); if (errCode != E_OK) { - LOGE("[MultiVerSyncTaskContext] timeHelper Initialize failed, err %d.", errCode); + LOGE("[MultiVerSyncTaskContext][Initialize] timeHelper Initialize failed, err=%d.", errCode); return errCode; } stateMachine_ = new (std::nothrow) MultiVerSyncStateMachine; if (stateMachine_ == nullptr) { + LOGE("[MultiVerSyncTaskContext][Initialize] stateMachine_ is nullptr."); return -E_OUT_OF_MEMORY; } @@ -65,6 +67,7 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf int MultiVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) { if (operation == nullptr) { + LOGE("[MultiVerSyncTaskContext][AddSyncOperation] operation is nullptr"); return -E_INVALID_ARGS; } @@ -76,6 +79,7 @@ int MultiVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) MultiVerSyncTarget *target = new (std::nothrow) MultiVerSyncTarget; if (target == nullptr) { + LOGE("[MultiVerSyncTaskContext][AddSyncOperation] target is nullptr"); return -E_OUT_OF_MEMORY; } target->SetSyncOperation(operation); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp index 65ac108a1..1167508c0 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp @@ -36,7 +36,7 @@ MultiVerSyncer::~MultiVerSyncer() void MultiVerSyncer::EnableAutoSync(bool enable) { - LOGD("[Syncer] EnableAutoSync enable = %d", enable); + LOGD("[Syncer] EnableAutoSync enable = %d, autoSyncEnable_ = %d", enable, autoSyncEnable_); if (autoSyncEnable_ == enable) { return; } @@ -49,12 +49,13 @@ void MultiVerSyncer::EnableAutoSync(bool enable) std::vector devices; GetOnlineDevices(devices); if (devices.empty()) { + LOGD("[Syncer] devices is empty"); return; } int errCode = Sync(devices, SyncModeType::AUTO_PULL, nullptr, nullptr, false); if (errCode != E_OK) { - LOGE("[Syncer] sync start by EnableAutoSync failed err %d", errCode); + LOGE("[Syncer] sync start by EnableAutoSync failed err=%d", errCode); } } @@ -85,13 +86,13 @@ void MultiVerSyncer::LocalDataChanged(int notifyEvent) void MultiVerSyncer::RemoteDataChanged(const std::string &device) { - LOGD("[MultiVerSyncer] Remote data changed or device online dev %s{private}", device.c_str()); + LOGD("[MultiVerSyncer] Remote data changed or device online dev=%s{private}", device.c_str()); if (autoSyncEnable_) { std::vector devices; devices.push_back(device); int errCode = Sync(devices, SyncModeType::AUTO_PULL, nullptr, nullptr, false); if (errCode != E_OK) { - LOGE("[MultiVerSyncer] sync start by RemoteDataChanged failed err %d", errCode); + LOGE("[MultiVerSyncer] sync start by RemoteDataChanged failed err=%d", errCode); } } } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp index 3a6a5cc65..19305a518 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp @@ -58,6 +58,7 @@ int LruMap::Get(const std::string &key, QueryWaterMark &outValue) { std::lock_guard autoLock(lruLock_); if (cache_.count(key) == 0) { + LOGE("[Meta]Get count key is zero"); return -E_NOT_FOUND; } outValue = cache_[key]; @@ -103,6 +104,7 @@ int LruMap::Elimination(const std::string &key, const QueryWaterMark &inQueryWat int QuerySyncWaterMarkHelper::GetMetadataFromDb(const std::vector &key, std::vector &outValue) { if (storage_ == nullptr) { + LOGE("[Meta]GetMetadataFromDb storage_ is nullptr"); return -E_INVALID_DB; } return storage_->GetMetaData(key, outValue); @@ -111,6 +113,7 @@ int QuerySyncWaterMarkHelper::GetMetadataFromDb(const std::vector &key, int QuerySyncWaterMarkHelper::SetMetadataToDb(const std::vector &key, const std::vector &inValue) { if (storage_ == nullptr) { + LOGE("[Meta]SetMetadataToDb storage_ is nullptr"); return -E_INVALID_DB; } return storage_->PutMetaData(key, inValue); @@ -119,6 +122,7 @@ int QuerySyncWaterMarkHelper::SetMetadataToDb(const std::vector &key, c int QuerySyncWaterMarkHelper::DeleteMetaDataFromDB(const std::vector &keys) const { if (storage_ == nullptr) { + LOGE("[Meta]DeleteMetaDataFromDB storage_ is nullptr"); return -E_INVALID_DB; } return storage_->DeleteMetaData(keys); @@ -135,12 +139,14 @@ int QuerySyncWaterMarkHelper::LoadDeleteSyncDataToCache(const Key &deleteWaterMa std::vector value; int errCode = GetMetadataFromDb(deleteWaterMarkKey, value); if (errCode != E_OK) { + LOGE("[Meta]LoadDeleteSyncDataToCache GetMetadataFromDb error, errCode=%d", errCode); return errCode; } DeleteWaterMark deleteWaterMark; std::string dbKey(deleteWaterMarkKey.begin(), deleteWaterMarkKey.end()); errCode = DeSerializeDeleteWaterMark(value, deleteWaterMark); if (errCode != E_OK) { + LOGE("[Meta]LoadDeleteSyncDataToCache DeSerializeDeleteWaterMark error, errCode=%d", errCode); return errCode; } std::lock_guard autoLock(deleteSyncLock_); @@ -153,6 +159,7 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkInCacheAndDb(const std::string &c { // first get from cache_ int errCode = querySyncCache_.Get(cacheKey, queryWaterMark); + LOGD("[Meta]GetQueryWaterMark get code=%d", errCode); bool addToCache = false; if (errCode == -E_NOT_FOUND) { // second get from db @@ -165,7 +172,6 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkInCacheAndDb(const std::string &c } // something error return if (errCode != E_OK) { - LOGE("[Meta]GetQueryWaterMark Fail code = %d", errCode); return errCode; } // remember add to cache_ @@ -202,6 +208,7 @@ int QuerySyncWaterMarkHelper::SetLastQueryTime(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = GetQueryWaterMarkInCacheAndDb(cacheKey, queryWaterMark); if (errCode != E_OK) { + LOGE("[Meta]SetLastQueryTime GetQueryWaterMark error, errCode=%d", errCode); return errCode; } queryWaterMark.lastQueryTime = timeStamp; @@ -214,6 +221,7 @@ int QuerySyncWaterMarkHelper::SetRecvQueryWaterMarkWithoutLock(const std::string QueryWaterMark queryWaterMark; int errCode = GetQueryWaterMarkInCacheAndDb(cacheKey, queryWaterMark); if (errCode != E_OK) { + LOGE("[Meta]SetRecvQueryWaterMarkWithoutLock GetQueryWaterMark error, errCode=%d", errCode); return errCode; } queryWaterMark.recvWaterMark = waterMark; @@ -241,6 +249,7 @@ int QuerySyncWaterMarkHelper::UpdateCacheAndSave(const std::string &cacheKey, // update lastUsedTime int errCode = OS::GetCurrentSysTimeInMicrosecond(queryWaterMark.lastUsedTime); if (errCode != E_OK) { + LOGE("[Meta]UpdateCacheAndSave GetCurrentSysTimeInMicrosecond failed, errCode=%d", errCode); return errCode; } // save db first @@ -256,6 +265,7 @@ int QuerySyncWaterMarkHelper::PutQueryWaterMarkToDB(const DeviceID &dbKeyString, { int errCode = OS::GetCurrentSysTimeInMicrosecond(queryWaterMark.lastUsedTime); if (errCode != E_OK) { + LOGE("[Meta]PutQueryWaterMarkToDB GetCurrentSysTimeInMicrosecond failed, errCode=%d", errCode); return errCode; } queryWaterMark.version = QUERY_WATERMARK_VERSION_CURRENT; @@ -268,6 +278,7 @@ int QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB(const DeviceID &dbKeyString Value dbValue; int errCode = SerializeQueryWaterMark(queryWaterMark, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB SerializeQueryWaterMark failed errCode=%d", errCode); return errCode; } // serialize key @@ -276,7 +287,7 @@ int QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB(const DeviceID &dbKeyString // save errCode = SetMetadataToDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB failed errCode:%d", errCode); + LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB SetMetadataToDb failed errCode=%d", errCode); } return errCode; } @@ -290,6 +301,7 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkFromDB(const DeviceID &dbKeyStrin Value dbValue; int errCode = GetMetadataFromDb(dbKey, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::GetQueryWaterMarkFromDB GetMetadataFromDb failed errCode=%d", errCode); return errCode; } return DeSerializeQueryWaterMark(dbValue, queryWaterMark); @@ -434,6 +446,7 @@ int QuerySyncWaterMarkHelper::GetDeleteWaterMarkFromDB(const DeviceID &hashDevic Value dbValue; int errCode = GetMetadataFromDb(dbKey, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::GetDeleteWaterMarkFromDB GetMetadataFromDb failed errCode=%d", errCode); return errCode; } // serialize value @@ -447,6 +460,7 @@ int QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB(const DeviceID &hashDevice Value dbValue; int errCode = SerializeDeleteWaterMark(deleteWaterMark, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB SerializeDeleteWaterMark failed errCode=%d", errCode); return errCode; } Key dbKey; @@ -454,7 +468,7 @@ int QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB(const DeviceID &hashDevice // save errCode = SetMetadataToDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB failed errCode:%d", errCode); + LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB failed errCode=%d", errCode); } return errCode; } @@ -584,7 +598,7 @@ int QuerySyncWaterMarkHelper::ResetRecvQueryWaterMark(const DeviceID &deviceId, DBCommon::StringToVector(prefixKeyStr, prefixKey); int errCode = storage_->DeleteMetaDataByPrefixKey(prefixKey); if (errCode != E_OK) { - LOGE("[META]ResetRecvQueryWaterMark fail errCode:%d", errCode); + LOGE("[META]ResetRecvQueryWaterMark fail errCode=%d", errCode); return errCode; } // clean cache diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp index 2157f5065..4127be1fa 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp @@ -35,6 +35,7 @@ void SingleVerDataMessageSchedule::Initialize(const std::string &label, const st void SingleVerDataMessageSchedule::PutMsg(Message *inMsg) { if (inMsg == nullptr) { + LOGE("[DataMsgSchedule] inMsg is nullptr"); return; } std::lock_guard lock(queueLock_); @@ -69,7 +70,6 @@ Message *SingleVerDataMessageSchedule::MoveNextMsg(SingleVerSyncTaskContext *con Message *msg = GetMsgFromMap(isNeedHandle); isNeedContinue = true; if (msg == nullptr) { - StopTimer(); std::lock_guard lock(workingLock_); isWorking_ = false; return nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp index 0b52e0528..3958e63a1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp @@ -166,6 +166,7 @@ uint32_t DataRequestPacket::CalculateLen(uint32_t messageId) const } totalLen = Parcel::GetEightByteAlign(totalLen); // 8-byte align if (totalLen > INT32_MAX) { + LOGE("[DataRequestPacket][CalculateLen] Parcel GetEightByteAlign > INT32_MAX"); return 0; } if (messageId == QUERY_SYNC_MESSAGE) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp index 8946b09c7..f6e9ecce9 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp @@ -521,7 +521,7 @@ int ValueSliceSync::GetValidValueSliceHashNode(MultiVerSyncTaskContext *context, int ValueSliceSync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("ValueSliceSync::Send ERR! err = %d", errCode); diff --git a/services/distributeddataservice/service/kv/user_delegate.cpp b/services/distributeddataservice/service/kv/user_delegate.cpp index 3f35b4ed8..d8055cbef 100644 --- a/services/distributeddataservice/service/kv/user_delegate.cpp +++ b/services/distributeddataservice/service/kv/user_delegate.cpp @@ -58,7 +58,7 @@ std::vector UserDelegate::GetUsers(const std::string &deviceId) for (const auto &entry : deviceUserMap_[deviceId]) { userStatus.emplace_back(entry.first, entry.second); } - ZLOGI("device:%{public}.10s, users:%{public}s", deviceId.c_str(), Serializable::Marshall(userStatus).c_str()); + ZLOGI("device=%{public}.10s, users=%{public}s", deviceId.c_str(), Serializable::Marshall(userStatus).c_str()); return userStatus; } @@ -69,7 +69,7 @@ void UserDelegate::DeleteUsers(const std::string &deviceId) void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector &userStatus) { - ZLOGI("begin, device:%{public}.10s, users:%{public}u", deviceId.c_str(), userStatus.size()); + ZLOGI("begin, device=%{public}.10s, users=%{public}u", deviceId.c_str(), userStatus.size()); deviceUserMap_.ComputeIfPresent(deviceId, [](const auto &key, std::map &userMap) { for (auto &user : userMap) { user.second = false; @@ -78,7 +78,7 @@ void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector osAccountIds = { { 0, true } }; // system user default auto ret = OsAccountManager::QueryActiveOsAccountIds(osAccountIds); if (ret != 0 || osAccountIds.empty()) { - ZLOGE("failed to query os accounts, ret:%{public}d", ret); + ZLOGE("failed to query os accounts, ret=%{public}d", ret); return false; } std::vector userStatus = { { 0, true } }; @@ -109,7 +109,7 @@ bool UserDelegate::InitLocalUserMeta() std::string jsonData = UserMetaData::Marshall(userMetaData); DistributedDB::Value dbValue{ jsonData.begin(), jsonData.end() }; ret = metaDelegate->Put(dbKey, dbValue); - ZLOGI("put user meta data ret %{public}d", ret); + ZLOGI("put user meta data ret=%{public}d", ret); return ret == DistributedDB::DBStatus::OK; } @@ -125,7 +125,7 @@ void UserDelegate::LoadFromMeta(const std::string &deviceId) DistributedDB::Value dbValue; auto ret = metaDelegate->Get(dbKey, dbValue); UserMetaData userMetaData; - ZLOGI("get user meta data ret %{public}d", ret); + ZLOGI("get user meta data ret=%{public}d", ret); if (ret != DistributedDB::DBStatus::OK) { return; } @@ -163,7 +163,7 @@ void UserDelegate::Init() [this](const std::vector &key, const std::vector &value, CHANGE_FLAG flag) { UserMetaData metaData; metaData.Unmarshall({ value.begin(), value.end() }); - ZLOGD("flag:%{public}d, value:%{public}.10s", flag, metaData.deviceId.c_str()); + ZLOGD("flag=%{public}d, value=%{public}.10s", flag, metaData.deviceId.c_str()); if (metaData.deviceId == DeviceKvStoreImpl::GetLocalDeviceId()) { ZLOGD("ignore local device user meta change"); return; @@ -176,7 +176,7 @@ void UserDelegate::Init() ZLOGD("ignored operation"); } }); - ZLOGD("subscribe os account ret:%{public}d", ret); + ZLOGD("subscribe os account ret=%{public}d", ret); } bool UserDelegate::NotifyUserEvent(const UserDelegate::UserEvent &userEvent) @@ -191,7 +191,7 @@ UserDelegate::LocalUserObserver::LocalUserObserver(UserDelegate &userDelegate) : void UserDelegate::LocalUserObserver::OnAccountChanged(const DistributedKv::AccountEventInfo &eventInfo) { - ZLOGI("event info:%{public}s, %{public}d", eventInfo.deviceAccountId.c_str(), eventInfo.status); + ZLOGI("event info=%{public}s, status=%{public}d", eventInfo.deviceAccountId.c_str(), eventInfo.status); userDelegate_.NotifyUserEvent({}); // just notify } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 1a98804fe..c2e9f268e 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -213,6 +213,7 @@ std::shared_ptr RdbServiceImpl::GetRdbSyncer(const RdbSyncerParam &pa } auto syncer_ = std::make_shared(param, new (std::nothrow) RdbStoreObserverImpl(this, pid)); if (syncer_->Init(pid, uid) != 0) { + ZLOGE("init syncer error"); return false; } syncers[param.storeName_] = syncer_; @@ -236,6 +237,7 @@ int32_t RdbServiceImpl::SetDistributedTables(const RdbSyncerParam ¶m, const ZLOGI("enter"); auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { + ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->SetDistributedTables(tables); @@ -246,6 +248,7 @@ int32_t RdbServiceImpl::DoSync(const RdbSyncerParam ¶m, const SyncOption &op { auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { + ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->DoSync(option, predicates, result); @@ -266,6 +269,7 @@ int32_t RdbServiceImpl::DoAsync(const RdbSyncerParam ¶m, uint32_t seqNum, co ZLOGI("seq num=%{public}u", seqNum); auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { + ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->DoAsync(option, predicates, diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp index 1de876eea..454226871 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp @@ -36,6 +36,7 @@ int32_t RdbServiceStub::OnRemoteObtainDistributedTableName(MessageParcel &data, return RDB_OK; } + ZLOGI("successful"); reply.WriteString(ObtainDistributedTableName(device, table)); return RDB_OK; } @@ -60,7 +61,7 @@ int32_t RdbServiceStub::OnRemoteInitNotifier(MessageParcel &data, MessageParcel reply.WriteInt32(error); return RDB_OK; } - ZLOGI("success"); + ZLOGI("successful"); reply.WriteInt32(RDB_OK); return RDB_OK; } @@ -102,10 +103,12 @@ int32_t RdbServiceStub::OnRemoteDoSync(MessageParcel &data, MessageParcel &reply SyncResult result; if (DoSync(param, option, predicates, result) != RDB_OK) { + ZLOGE("DoSync failed"); reply.WriteInt32(RDB_ERROR); return RDB_OK; } if (!DistributedKv::ITypesUtil::Marshalling(result, reply)) { + ZLOGE("Marshalling failed"); reply.WriteInt32(RDB_ERROR); return RDB_OK; } @@ -182,6 +185,7 @@ int RdbServiceStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageP { ZLOGI("code=%{public}d", code); if (!CheckInterfaceToken(data)) { + ZLOGE("check interface token failed"); return RDB_ERROR; } if (code >= 0 && code < RDB_SERVICE_CMD_MAX) { diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.cpp b/services/distributeddataservice/service/rdb/rdb_syncer.cpp index a1813e3b2..2856a5059 100644 --- a/services/distributeddataservice/service/rdb/rdb_syncer.cpp +++ b/services/distributeddataservice/service/rdb/rdb_syncer.cpp @@ -101,7 +101,7 @@ int32_t RdbSyncer::Init(pid_t pid, pid_t uid) ZLOGE("create meta data failed"); return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); return RDB_OK; } @@ -153,7 +153,7 @@ DistributedDB::RelationalStoreDelegate* RdbSyncer::GetDelegate() ZLOGE("open store failed status=%{public}d", status); return nullptr; } - ZLOGI("open store success"); + ZLOGI("open store successful"); } return delegate_; @@ -174,7 +174,7 @@ int32_t RdbSyncer::SetDistributedTables(const std::vector &tables) return RDB_ERROR; } } - ZLOGE("create distributed table success"); + ZLOGE("create distributed table successful"); return RDB_OK; } -- Gitee From d458becb81e3b551940c9a7a7c70b76260713e5c Mon Sep 17 00:00:00 2001 From: "kaixuan.shao" Date: Mon, 21 Mar 2022 16:13:58 +0800 Subject: [PATCH 2/3] log fix --- .../distributeddatafwk/src/app_blob.cpp | 0 .../src/app_change_notification.cpp | 0 .../src/app_distributed_kv_data_manager.cpp | 0 .../app_distributed_kv_data_manager_impl.cpp | 20 ++-- .../src/app_kvstore_conflict_data_impl.cpp | 0 .../src/app_kvstore_impl.cpp | 55 ++--------- .../src/app_kvstore_result_set_impl.cpp | 3 - .../distributeddatafwk/src/blob.cpp | 0 .../src/change_notification.cpp | 13 +-- .../distributeddatafwk/src/data_query.cpp | 0 .../device_status_change_listener_client.cpp | 0 .../src/distributed_kv_data_manager.cpp | 8 +- .../idevice_status_change_listener_impl.cpp | 2 +- .../distributeddatafwk/src/ikvstore.cpp | 48 +++++---- .../src/ikvstore_data_service.cpp | 50 +++------- .../src/ikvstore_observer.cpp | 4 +- .../src/ikvstore_resultset.cpp | 16 ++- .../src/ikvstore_single.cpp | 98 +++++++------------ .../src/ikvstore_snapshot.cpp | 26 ++--- .../src/ikvstore_sync_callback.cpp | 2 +- .../distributeddatafwk/src/itypes_util.cpp | 21 ---- .../distributeddatafwk/src/kvstore_client.cpp | 8 +- .../src/kvstore_client_death_observer.cpp | 0 .../src/kvstore_observer_client.cpp | 0 .../src/kvstore_resultset_client.cpp | 5 +- .../src/kvstore_service_death_notifier.cpp | 11 +-- .../src/kvstore_snapshot_client.cpp | 2 - .../src/kvstore_sync_callback_client.cpp | 2 +- .../src/single_kvstore_client.cpp | 15 +-- .../rdb/src/rdb_manager_impl.cpp | 7 +- .../innerkitsimpl/rdb/src/rdb_notifier.cpp | 2 - .../rdb/src/rdb_service_proxy.cpp | 15 ++- .../distributeddata/src/entry_point.cpp | 10 +- .../src/js_device_kv_store.cpp | 25 +++-- .../distributeddata/src/js_field_node.cpp | 3 - .../distributeddata/src/js_kv_manager.cpp | 21 ++-- .../distributeddata/src/js_kv_store.cpp | 37 +++---- .../src/js_kv_store_resultset.cpp | 3 +- .../distributeddata/src/js_observer.cpp | 60 ++++++++++++ .../distributeddata/src/js_query.cpp | 9 -- .../distributeddata/src/js_schema.cpp | 5 - .../src/js_single_kv_store.cpp | 23 +++-- .../distributeddata/src/js_util.cpp | 5 +- .../distributeddata/src/napi_queue.cpp | 2 - .../distributeddata/src/uv_queue.cpp | 2 +- .../adapter/account/src/account_delegate.cpp | 0 .../account/src/account_delegate_impl.cpp | 0 .../adapter/autils/src/constant.cpp | 0 .../adapter/autils/src/directory_utils.cpp | 0 .../adapter/autils/src/kv_scheduler.cpp | 0 .../autils/src/thread_pool/kv_store_task.cpp | 0 .../src/thread_pool/kv_store_thread.cpp | 6 -- .../src/thread_pool/kv_store_thread_pool.cpp | 0 .../thread_pool/kv_store_thread_pool_impl.cpp | 0 .../test/unittest/kv_scheduler_test.cpp | 0 .../broadcaster/src/broadcast_sender.cpp | 0 .../broadcaster/src/broadcast_sender_impl.cpp | 0 .../communicator/src/app_device_handler.cpp | 0 .../communicator/src/app_pipe_handler.cpp | 0 .../adapter/communicator/src/app_pipe_mgr.cpp | 0 .../src/ark_communication_provider.cpp | 0 .../src/communication_provider_impl.cpp | 0 .../adapter/communicator/src/data_buffer.cpp | 8 ++ .../src/process_communicator_impl.cpp | 0 .../src/softbus_adapter_standard.cpp | 2 +- .../adapter/dfx/src/dds_trace.cpp | 0 .../src/fault/communication_fault_impl.cpp | 0 .../dfx/src/fault/database_fault_impl.cpp | 0 .../adapter/dfx/src/fault/fault_reporter.cpp | 0 .../dfx/src/fault/runtime_fault_impl.cpp | 0 .../dfx/src/fault/service_fault_impl.cpp | 0 .../adapter/dfx/src/hiview_adapter.cpp | 0 .../adapter/dfx/src/reporter.cpp | 0 .../api_performance_statistic_impl.cpp | 0 .../src/statistic/database_statistic_impl.cpp | 0 .../dfx/src/statistic/statistic_reporter.cpp | 0 .../src/statistic/traffic_statistic_impl.cpp | 0 .../src/statistic/visit_statistic_impl.cpp | 0 .../src/client_permission_validator.cpp | 0 .../permission/src/permission_validator.cpp | 0 .../unittest/permission_validator_test.cpp | 0 .../adapter/utils/src/kvstore_utils.cpp | 0 .../app/src/backup_handler.cpp | 0 .../kvstore_flowctrl_manager.cpp | 0 .../app/src/kvstore_account_observer.cpp | 0 .../app/src/kvstore_app_accessor.cpp | 0 .../app/src/kvstore_app_manager.cpp | 2 +- .../app/src/kvstore_impl.cpp | 0 .../app/src/kvstore_meta_manager.cpp | 0 .../app/src/kvstore_resultset_impl.cpp | 0 .../app/src/kvstore_snapshot_impl.cpp | 0 .../app/src/kvstore_sync_manager.cpp | 0 .../app/src/kvstore_user_manager.cpp | 0 .../app/src/security/security.cpp | 1 - .../route_head_handler_impl.cpp | 16 ++- .../src/session_manager/session_manager.cpp | 16 ++- .../app/src/single_kvstore_impl.cpp | 0 .../app/src/uninstaller/uninstaller.cpp | 0 .../app/src/uninstaller/uninstaller_impl.cpp | 0 .../distributeddb/common/src/auto_launch.cpp | 75 +++++++++----- .../common/src/param_check_utils.cpp | 1 - .../common/src/platform_specific.cpp | 2 +- .../communicator/src/communicator.cpp | 2 +- .../src/communicator_aggregator.cpp | 6 +- .../communicator/src/protocol_proto.cpp | 28 ++++-- .../relational_store_delegate_impl.cpp | 2 +- .../storage/src/operation/database_oper.cpp | 2 - .../storage/src/sqlite/query_object.cpp | 88 ++++++++++------- .../storage/src/sqlite/query_sync_object.cpp | 8 +- .../sqlite_relational_store_connection.cpp | 1 - .../sqlite_single_ver_database_upgrader.cpp | 4 +- .../sqlite_single_ver_natural_store.cpp | 8 +- ...te_single_ver_natural_store_connection.cpp | 28 +++--- ...single_ver_relational_storage_executor.cpp | 8 +- .../sqlite_single_ver_storage_engine.cpp | 13 +++ .../sqlite_single_ver_storage_executor.cpp | 18 ++-- ...lite_single_ver_storage_executor_cache.cpp | 7 +- .../storage/src/sqlite/sqlite_utils.cpp | 64 +++++++----- .../storage/src/storage_engine.cpp | 7 +- .../upgrader/single_ver_database_upgrader.cpp | 15 ++- .../distributeddb/syncer/src/ability_sync.cpp | 91 +++++------------ .../syncer/src/commit_history_sync.cpp | 60 ++---------- .../syncer/src/communicator_proxy.cpp | 3 - .../syncer/src/device_manager.cpp | 7 +- .../syncer/src/generic_syncer.cpp | 44 +++------ .../distributeddb/syncer/src/meta_data.cpp | 39 ++------ .../syncer/src/multi_ver_data_sync.cpp | 51 ++-------- .../src/multi_ver_sync_state_machine.cpp | 46 +++------ .../src/multi_ver_sync_task_context.cpp | 6 +- .../syncer/src/multi_ver_syncer.cpp | 9 +- .../src/query_sync_water_mark_helper.cpp | 22 +---- .../src/single_ver_data_message_schedule.cpp | 2 +- .../syncer/src/single_ver_data_packet.cpp | 1 - .../syncer/src/value_slice_sync.cpp | 2 +- .../service/kv/user_delegate.cpp | 18 ++-- .../service/rdb/rdb_service_impl.cpp | 4 - .../service/rdb/rdb_service_stub.cpp | 6 +- .../service/rdb/rdb_syncer.cpp | 6 +- 138 files changed, 621 insertions(+), 872 deletions(-) mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_blob.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_change_notification.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_conflict_data_impl.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/blob.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/data_query.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/device_status_change_listener_client.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client_death_observer.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_observer_client.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp mode change 100755 => 100644 frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp create mode 100644 frameworks/jskitsimpl/distributeddata/src/js_observer.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/account/src/account_delegate.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/constant.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/directory_utils.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/kv_scheduler.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_task.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/autils/test/unittest/kv_scheduler_test.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/broadcaster/src/broadcast_sender.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/broadcaster/src/broadcast_sender_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/app_device_handler.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/ark_communication_provider.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/communication_provider_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/data_buffer.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/process_communicator_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/dds_trace.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/reporter.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/permission/src/client_permission_validator.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/permission/src/permission_validator.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/permission/test/unittest/permission_validator_test.cpp mode change 100755 => 100644 services/distributeddataservice/adapter/utils/src/kvstore_utils.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/backup_handler.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_account_observer.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_app_accessor.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_app_manager.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_impl.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_meta_manager.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_resultset_impl.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_snapshot_impl.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_sync_manager.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/kvstore_user_manager.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/single_kvstore_impl.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/uninstaller/uninstaller.cpp mode change 100755 => 100644 services/distributeddataservice/app/src/uninstaller/uninstaller_impl.cpp diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_blob.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_blob.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_change_notification.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_change_notification.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp old mode 100755 new mode 100644 index fc004122b..afa655fa4 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp @@ -47,12 +47,11 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge std::lock_guard lck(storeMutex_); auto it = managers_.find(bundleName + userId); if (it != managers_.end()) { - ZLOGI("manager has been found"); return it->second; } std::string tempDataDir = dataDir; - ZLOGD("tempDataDir = %s", tempDataDir.c_str()); + ZLOGD("tempDataDir : %s", tempDataDir.c_str()); if (!ForceCreateDirectory(tempDataDir)) { ZLOGE("create directories %s failed", tempDataDir.c_str()); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_CREATE_DIR}; @@ -61,7 +60,6 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge } // default mode is 0755 if (!ChangeModeDirectory(tempDataDir, DistributedKv::Constant::DEFAULT_MODE)) { - ZLOGI("tempDataDir is default mode."); return nullptr; } @@ -71,7 +69,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge } auto status = DistributedDB::KvStoreDelegateManager::SetProcessLabel(appId + DEVICE_COLLABORATION_ABBRE, userId); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("delegate SetProcessLabel failed=%d.", static_cast(status)); + ZLOGE("delegate SetProcessLabel failed: %d.", static_cast(status)); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_PROCESS_LABEL}; Reporter::GetInstance()->ServiceFault()->Report(msg); return nullptr; @@ -80,7 +78,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge auto communicator = std::make_shared(); auto commStatus = DistributedDB::KvStoreDelegateManager::SetProcessCommunicator(communicator); if (commStatus != DistributedDB::DBStatus::OK) { - ZLOGW("set distributed db communicator failed=%d.", static_cast(status)); + ZLOGW("set distributed db communicator failed."); return nullptr; } @@ -92,7 +90,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge DistributedDB::KvStoreConfig kvStoreConfig { tempDataDir }; status = delegateManager->SetKvStoreConfig(kvStoreConfig); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("delegate SetKvStoreConfig failed=%d.", static_cast(status)); + ZLOGE("delegate SetKvStoreConfig failed: %d.", static_cast(status)); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_DATABASE_CONFIG}; Reporter::GetInstance()->ServiceFault()->Report(msg); delete delegateManager; @@ -168,7 +166,7 @@ Status AppDistributedKvDataManagerImpl::GetKvStore( Reporter::GetInstance()->ServiceFault()->Report(msg); }); - ZLOGI("get status=%d.", static_cast(status)); + ZLOGI("get status: %d.", static_cast(status)); return status; } @@ -203,7 +201,7 @@ Status AppDistributedKvDataManagerImpl::DeleteKvStore(const std::string &storeId ZLOGI("delete KVStore succeed."); return Status::SUCCESS; } - ZLOGE("delete KVStore failed, status=%d", static_cast(status)); + ZLOGE("delete KVStore failed."); return Status::ERROR; } @@ -216,10 +214,10 @@ Status AppDistributedKvDataManagerImpl::GetKvStoreDiskSize(const std::string &st } DistributedDB::DBStatus status = kvStoreDelegateManager_->GetKvStoreDiskSize(storeId, size); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to getStoreDiskSize, storeID: %s, status=%d", storeId.c_str(), static_cast(status)); + ZLOGE("Failed to getStoreDiskSize, storeID: %s", storeId.c_str()); return Status::ERROR; } - ZLOGI("end, size=%" PRIu64, size); + ZLOGI("end, size:%" PRIu64, size); return Status::SUCCESS; } @@ -235,7 +233,6 @@ Status AppDistributedKvDataManagerImpl::RegisterKvStoreCorruptionObserver( return Status::REPEATED_REGISTER; } if (kvStoreDelegateManager_ == nullptr) { - ZLOGE("kvStoreDelegateManager_ is nullptr."); return Status::ERROR; } corruptionObserver_ = observer; @@ -250,7 +247,6 @@ Status AppDistributedKvDataManagerImpl::RegisterKvStoreCorruptionObserver( DistributedDB::SecurityOption AppDistributedKvDataManagerImpl::ConvertSecurityLevel(int securityLevel) { if (securityLevel < SecurityLevel::NO_LABEL || securityLevel > SecurityLevel::S4) { - ZLOGD("SecurityLevel not correct"); return {SecurityLevel::NO_LABEL, DistributedDB::ECE}; } switch (securityLevel) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_conflict_data_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_conflict_data_impl.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp old mode 100755 new mode 100644 index 7e4080a71..2ce544b7a --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp @@ -86,7 +86,7 @@ Status AppKvStoreImpl::Put(const WriteOptions &options, const Key &key, const Va Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGE("put failed. status=%d.", static_cast(status)); + ZLOGW("put failed. status: %d.", static_cast(status)); return ConvertErrorCode(status); } @@ -111,7 +111,7 @@ Status AppKvStoreImpl::Delete(const WriteOptions &options, const Key &key) Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGE("failed status=%d.", static_cast(status)); + ZLOGW("failed status: %d.", static_cast(status)); return ConvertErrorCode(status); } @@ -124,7 +124,6 @@ Status AppKvStoreImpl::Get(const ReadOptions &options, const Key &key, Value &va ZLOGD("start"); auto trimmedKey = DistributedKv::Constant::TrimCopy>(key.Data()); if (trimmedKey.size() == 0 || trimmedKey.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { - ZLOGE("trimmedKey size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKey = trimmedKey; @@ -143,7 +142,6 @@ Status AppKvStoreImpl::Get(const ReadOptions &options, const Key &key, Value &va Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGE("get key-value error, errCode=%d", status); return ConvertErrorCode(status); } @@ -156,7 +154,6 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr ZLOGD("start."); auto trimmedPrefix = DistributedKv::Constant::TrimCopy>(prefixKey.Data()); if (trimmedPrefix.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { - ZLOGE("trimmedPrefix size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKeyPrefix = trimmedPrefix; @@ -164,7 +161,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr DistributedDB::DBStatus status = kvStoreNbDelegate_->GetEntries(tmpKeyPrefix, dbEntries); if (status == DistributedDB::DBStatus::OK) { entries.reserve(dbEntries.size()); - ZLOGD("vector size=%zu status=%d.", dbEntries.size(), static_cast(status)); + ZLOGD("vector size: %zu status: %d.", dbEntries.size(), static_cast(status)); for (auto const &dbEntry : dbEntries) { Key tmpKey(dbEntry.key); Value tmpValue(dbEntry.value); @@ -172,7 +169,6 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr } return Status::SUCCESS; } - ZLOGE("get entries error, errCode=%d", status); return ConvertErrorCode(status); } @@ -182,7 +178,6 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, AppKvStoreResultSet *&re ZLOGD("start."); auto trimmedPrefix = DistributedKv::Constant::TrimCopy>(prefixKey.Data()); if (trimmedPrefix.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { - ZLOGE("trimmedPrefix size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKeyPrefix = trimmedPrefix; @@ -191,50 +186,41 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, AppKvStoreResultSet *&re if (status == DistributedDB::DBStatus::OK) { resultSet = new (std::nothrow) AppKvStoreResultSetImpl(dbResultSet, kvStoreNbDelegate_); if (resultSet == nullptr) { - ZLOGE("new resultSet failed."); + ZLOGW("new resultSet failed."); return Status::ERROR; } return Status::SUCCESS; } - ZLOGE("get entries error, errCode=%d", status); return ConvertErrorCode(status); } // Close the result set returned by GetEntries(). Status AppKvStoreImpl::CloseResultSet(AppKvStoreResultSet *&resultSet) { - ZLOGD("start."); if (resultSet == nullptr) { - ZLOGE("resultSet is nullptr"); return Status::INVALID_ARGUMENT; } if (resultSet->Close() == Status::SUCCESS) { - ZLOGD("successful."); delete resultSet; resultSet = nullptr; return Status::SUCCESS; } - ZLOGE("close resultSet error."); return Status::ERROR; } // Close this kvstore in KvStoreDelegateManager. This method is called before this store object destruct. Status AppKvStoreImpl::Close(DistributedDB::KvStoreDelegateManager *kvStoreDelegateManager) { - ZLOGD("start."); if (kvStoreDelegateManager == nullptr) { - ZLOGE("kvStoreDelegateManager is nullptr"); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus status = kvStoreDelegateManager->CloseKvStore(kvStoreNbDelegate_); if (status == DistributedDB::DBStatus::OK) { - ZLOGD("successful."); VisitStat vs { appId_, __FUNCTION__ }; Reporter::GetInstance()->VisitStatistic()->Report(vs); return Status::SUCCESS; } - ZLOGE("close KvStore error, errCode=%d", status); return Status::ERROR; } @@ -284,7 +270,7 @@ Status AppKvStoreImpl::Sync(const std::vector &deviceIds, SyncMode callback(resultMap); }); - ZLOGD("end=%d", static_cast(status)); + ZLOGD("end: %d", static_cast(status)); Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (status == DistributedDB::DBStatus::OK) { return Status::SUCCESS; @@ -307,7 +293,6 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr { ZLOGD("start."); if (observer == nullptr) { - ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus dbStatus; @@ -321,7 +306,6 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr std::lock_guard lock(localObserverMapMutex_); bool alreadySubscribed = (localObserverMap_.find(observer) != localObserverMap_.end()); if (alreadySubscribed) { - ZLOGD("store alreadly subscribe."); delete nbObserver; return Status::STORE_ALREADY_SUBSCRIBE; } @@ -329,14 +313,12 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr dbStatus = kvStoreNbDelegate_->RegisterObserver( emptyKey, DistributedDB::ObserverMode::OBSERVER_CHANGES_LOCAL_ONLY, nbObserver); if (dbStatus == DistributedDB::DBStatus::OK) { - ZLOGD("successful."); localObserverMap_.insert(std::pair(observer, nbObserver)); } } else { std::lock_guard lock(syncedObserverMapMutex_); bool alreadySubscribed = (syncedObserverMap_.find(observer) != syncedObserverMap_.end()); if (alreadySubscribed) { - ZLOGD("store alreadly subscribe."); delete nbObserver; return Status::STORE_ALREADY_SUBSCRIBE; } @@ -356,20 +338,16 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr } Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (dbStatus == DistributedDB::DBStatus::OK) { - ZLOGD("successful."); return Status::SUCCESS; } delete nbObserver; if (dbStatus == DistributedDB::DBStatus::INVALID_ARGS) { - ZLOGE("Invalid args."); return Status::INVALID_ARGUMENT; } if (dbStatus == DistributedDB::DBStatus::DB_ERROR) { - ZLOGE("db error."); return Status::DB_ERROR; } - ZLOGE("error."); return Status::ERROR; } @@ -387,7 +365,6 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs { ZLOGD("start."); if (observer == nullptr) { - ZLOGE("observer is nullptr."); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus dbStatus; @@ -395,7 +372,6 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs std::lock_guard lock(localObserverMapMutex_); auto nbObserver = localObserverMap_.find(observer); if (nbObserver == localObserverMap_.end()) { - ZLOGD("store not subscribe"); return Status::STORE_NOT_SUBSCRIBE; } dbStatus = kvStoreNbDelegate_->UnRegisterObserver(nbObserver->second); @@ -407,7 +383,6 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs std::lock_guard lock(syncedObserverMapMutex_); auto nbObserver = syncedObserverMap_.find(observer); if (nbObserver == syncedObserverMap_.end()) { - ZLOGD("store not subscribe."); return Status::STORE_NOT_SUBSCRIBE; } dbStatus = kvStoreNbDelegate_->UnRegisterObserver(nbObserver->second); @@ -418,18 +393,14 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs } Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (dbStatus == DistributedDB::DBStatus::OK) { - ZLOGD("successful."); return Status::SUCCESS; } if (dbStatus == DistributedDB::DBStatus::NOT_FOUND) { - ZLOGE("store not subscribe.."); return Status::STORE_NOT_SUBSCRIBE; } if (dbStatus == DistributedDB::DBStatus::INVALID_ARGS) { - ZLOGE("invalid args."); return Status::INVALID_ARGUMENT; } - ZLOGE("db error."); return Status::ERROR; } @@ -440,7 +411,6 @@ Status AppKvStoreImpl::RemoveDeviceData(const std::string &device) if (status == DistributedDB::DBStatus::OK) { return Status::SUCCESS; } - ZLOGW("RemoveDeviceData error, errCode=%d", status); return Status::ERROR; } @@ -459,7 +429,6 @@ Status AppKvStoreImpl::SetConflictResolutionPolicy( callback(appConflictDataImpl); }); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("error, status=%d", dbStatus); return Status::DB_ERROR; } return Status::SUCCESS; @@ -468,7 +437,6 @@ Status AppKvStoreImpl::SetConflictResolutionPolicy( void AppKvStoreImpl::FormKvStoreConflictEntry(const DistributedDB::KvStoreNbConflictData &data, KvStoreConflictEntry &kvstoreConflictEntry) { - ZLOGD("start."); kvstoreConflictEntry.type = data.GetType(); DistributedDB::Key dbKey; data.GetKey(dbKey); @@ -484,7 +452,6 @@ void AppKvStoreImpl::FormKvStoreConflictData(const DistributedDB::KvStoreNbConfl DistributedDB::KvStoreNbConflictData::ValueType type, KvStoreConflictData &kvStoreConflictData) { - ZLOGD("start."); DistributedDB::DBStatus dbStatus; kvStoreConflictData.isLocal = data.IsNative(type); kvStoreConflictData.isDeleted = data.IsDeleted(type); @@ -492,7 +459,7 @@ void AppKvStoreImpl::FormKvStoreConflictData(const DistributedDB::KvStoreNbConfl DistributedDB::Value dbValue; dbStatus = data.GetValue(type, dbValue); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to handle conflict, error: bad conflict data status=%d", dbStatus); + ZLOGE("Failed to handle conflict, error: bad conflict data"); kvStoreConflictData.status = Status::DB_ERROR; return; } @@ -506,18 +473,17 @@ Status AppKvStoreImpl::Export(const std::string &filePath, const std::vectorExport(filePath, password); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to export, path=%s, status=%d", filePath.c_str(), dbStatus); + ZLOGE("Failed to export, path:%s", filePath.c_str()); return Status::DB_ERROR; } ZLOGD("export end"); @@ -528,18 +494,17 @@ Status AppKvStoreImpl::Import(const std::string &filePath, const std::vectorImport(filePath, password); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to export, path=%s, status=%d", filePath.c_str(), dbStatus); + ZLOGE("Failed to export, path:%s", filePath.c_str()); return Status::DB_ERROR; } ZLOGD("Import end"); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp old mode 100755 new mode 100644 index 0c76ba3c3..0cecd9a0f --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp @@ -17,7 +17,6 @@ #include "app_kvstore_result_set_impl.h" #include "app_types.h" -#include "log_print.h" namespace OHOS { namespace AppDistributedKv { @@ -111,11 +110,9 @@ bool AppKvStoreResultSetImpl::IsAfterLast() const Status AppKvStoreResultSetImpl::GetEntry(Entry &entry) const { if (kvStoreResultSet_ == nullptr) { - ZLOGD("kvStoreResultSet_ is nullptr"); return Status::ERROR; } if (GetCount() == 0) { - ZLOGD("count is zero"); return Status::KEY_NOT_FOUND; } DistributedDB::Entry dbEntry; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/blob.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/blob.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp index 8d57dc012..1a7a14a09 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp @@ -58,42 +58,35 @@ bool ChangeNotification::IsClear() const bool ChangeNotification::Marshalling(Parcel &parcel) const { if (!parcel.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { - ZLOGE("SetMaxCapacity MAX_IPC_CAPACITY failed."); return false; } int32_t lenInsert = static_cast(insertEntries_.size()); if (!parcel.WriteInt32(lenInsert)) { - ZLOGE("WriteInt32 lenInsert failed."); return false; } for (const auto &entry : insertEntries_) { if (!parcel.WriteParcelable(&entry)) { - ZLOGE("WriteParcelable insertEntries_ entrys failed."); return false; } } int32_t lenUpdate = static_cast(updateEntries_.size()); if (!parcel.WriteInt32(lenUpdate)) { - ZLOGE("WriteInt32 lenUpdate failed."); return false; } for (const auto &entry : updateEntries_) { if (!parcel.WriteParcelable(&entry)) { - ZLOGE("WriteParcelable updateEntries_ entrys failed."); return false; } } int32_t lenDelete = static_cast(deleteEntries_.size()); if (!parcel.WriteInt32(lenDelete)) { - ZLOGE("WriteInt32 lenDelete failed."); return false; } for (const auto &entry : deleteEntries_) { if (!parcel.WriteParcelable(&entry)) { - ZLOGE("WriteParcelable deleteEntries_ entrys failed."); return false; } } @@ -113,7 +106,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenInsert = parcel.ReadInt32(); if (lenInsert < 0) { - ZLOGE("lenInsert = %d", lenInsert); + ZLOGE("lenInsert is %d", lenInsert); return nullptr; } for (int i = 0; i < lenInsert; i++) { @@ -128,7 +121,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenUpdate = parcel.ReadInt32(); if (lenUpdate < 0) { - ZLOGE("lenUpdate = %d", lenUpdate); + ZLOGE("lenUpdate is %d", lenUpdate); return nullptr; } for (int i = 0; i < lenUpdate; i++) { @@ -143,7 +136,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenDelete = parcel.ReadInt32(); if (lenDelete < 0) { - ZLOGE("lenDelete = %d", lenDelete); + ZLOGE("lenDelete is %d", lenDelete); return nullptr; } for (int i = 0; i < lenDelete; i++) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/data_query.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/data_query.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/device_status_change_listener_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/device_status_change_listener_client.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp index 6385d6aaf..58894cf8a 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp @@ -60,13 +60,13 @@ Status DistributedKvDataManager::GetKvStore(const Options &options, const AppId status = kvDataServiceProxy->GetKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (status == Status::RECOVER_SUCCESS) { - ZLOGE("proxy recover success=%d", static_cast(status)); + ZLOGE("proxy recover success: %d", static_cast(status)); kvStore = std::make_shared(std::move(proxyTmp), storeIdTmp); return status; } if (status != Status::SUCCESS) { - ZLOGE("proxy return error=%d", static_cast(status)); + ZLOGE("proxy return error: %d", static_cast(status)); return status; } @@ -103,13 +103,13 @@ Status DistributedKvDataManager::GetSingleKvStore(const Options &options, const status = kvDataServiceProxy->GetSingleKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (status == Status::RECOVER_SUCCESS) { - ZLOGE("proxy recover success=%d", static_cast(status)); + ZLOGE("proxy recover success: %d", static_cast(status)); singleKvStore = std::make_shared(std::move(proxyTmp), storeIdTmp); return status; } if (status != Status::SUCCESS) { - ZLOGE("proxy return error=%d", static_cast(status)); + ZLOGE("proxy return error: %d", static_cast(status)); return status; } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp old mode 100755 new mode 100644 index 9d6d3d1cc..2bb53ec31 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/idevice_status_change_listener_impl.cpp @@ -42,7 +42,7 @@ void DeviceStatusChangeListenerProxy::OnChange(const DeviceInfo &results, const MessageOption mo { MessageOption::TF_ASYNC }; int error = Remote()->SendRequest(ONCHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error=%d", error); + ZLOGW("SendRequest failed, error %d", error); } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp old mode 100755 new mode 100644 index 9609d6051..64500b51c --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp @@ -45,7 +45,6 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, std::function)> callback) { if (observer == nullptr) { - ZLOGW("observer is nullptr"); callback(Status::INVALID_ARGUMENT, nullptr); return; } @@ -63,7 +62,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETKVSTORESNAPSHOT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); callback(Status::IPC_ERROR, nullptr); return; } @@ -71,7 +70,6 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, if (status == Status::SUCCESS) { sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { - ZLOGW("ReadRemoteObject is nullptr"); callback(status, nullptr); return; } @@ -102,7 +100,7 @@ Status KvStoreImplProxy::ReleaseKvStoreSnapshot(sptr kvSto MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(RELEASEKVSTORESNAPSHOT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -135,7 +133,7 @@ Status KvStoreImplProxy::Put(const Key &key, const Value &value) MessageOption mo { MessageOption::TF_SYNC }; int error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed with error code=%d", error); + ZLOGW("SendRequest failed with error code %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -160,7 +158,7 @@ Status KvStoreImplProxy::Put(const Key &key, const Value &value) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -185,7 +183,6 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) int64_t bufferSize = 0; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { - ZLOGW("entrty size too long."); return Status::INVALID_ARGUMENT; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -203,7 +200,6 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) } MessageOption mo { MessageOption::TF_SYNC }; if (Remote()->SendRequest(PUTBATCH, data, reply, mo) != 0) { - ZLOGW("Remote SendRequest failed."); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -233,7 +229,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUTBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -253,7 +249,7 @@ Status KvStoreImplProxy::Delete(const Key &key) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -287,7 +283,7 @@ Status KvStoreImplProxy::DeleteBatch(const std::vector &keys) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -303,7 +299,7 @@ Status KvStoreImplProxy::Clear() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLEAR, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -319,7 +315,7 @@ Status KvStoreImplProxy::StartTransaction() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTTRANSACTION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -335,7 +331,7 @@ Status KvStoreImplProxy::Commit() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(COMMIT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -351,7 +347,7 @@ Status KvStoreImplProxy::Rollback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(ROLLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -378,7 +374,7 @@ Status KvStoreImplProxy::SubscribeKvStore(const SubscribeType subscribeType, spt MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -387,7 +383,6 @@ Status KvStoreImplProxy::SubscribeKvStore(const SubscribeType subscribeType, spt Status KvStoreImplProxy::UnSubscribeKvStore(const SubscribeType subscribeType, sptr observer) { if (observer == nullptr) { - ZLOGW("observer is invalid."); return Status::INVALID_ARGUMENT; } @@ -405,7 +400,7 @@ Status KvStoreImplProxy::UnSubscribeKvStore(const SubscribeType subscribeType, s MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest error=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -415,7 +410,6 @@ int32_t KvStoreImplStub::GetKvStoreSnapshotOnRemote(MessageParcel &data, Message { sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { - ZLOGW("remote is nullptr."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write obj failed."); return -1; @@ -466,12 +460,11 @@ int32_t KvStoreImplStub::PutOnRemoteRequest(MessageParcel &data, MessageParcel & return -1; } const int bufferSize = data.ReadInt32(); - ZLOGD("bufferSize=%d", bufferSize); + ZLOGD("bufferSize %d", bufferSize); if (bufferSize < Constant::SWITCH_RAW_DATA_SIZE) { sptr key = data.ReadParcelable(); sptr value = data.ReadParcelable(); if (key == nullptr || value == nullptr) { - ZLOGW("key or value is nullptr."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write key or val status failed."); return -1; @@ -480,7 +473,7 @@ int32_t KvStoreImplStub::PutOnRemoteRequest(MessageParcel &data, MessageParcel & } Status status = Put(*key, *value); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write *ret status failed."); + ZLOGW("write ret status failed."); return -1; } return 0; @@ -520,8 +513,9 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar } int len = data.ReadInt32(); if (len < 0) { - ZLOGW("invalid status. len=%d", len); + ZLOGW("invalid status. len %d", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("write putbatch failed."); return -1; } return 0; @@ -534,6 +528,7 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (entry == nullptr) { ZLOGW("putbatch got null entry pointer"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { + ZLOGW("write putbatch failed."); return -1; } return 0; @@ -552,6 +547,7 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (buffer == nullptr) { ZLOGW("buffer is null"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { + ZLOGW("write putbatch big failed."); return -1; } return 0; @@ -567,6 +563,7 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (!success) { ZLOGW("get key or value failed"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { + ZLOGW("write putbatch big failed."); return -1; } return 0; @@ -585,6 +582,7 @@ int32_t KvStoreImplStub::DeleteOnRemoteRequest(MessageParcel &data, MessageParce if (key == nullptr) { ZLOGW("key nullptr after ipc"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("write delete failed."); return -1; } return 0; @@ -600,7 +598,7 @@ int32_t KvStoreImplStub::DeleteBatchOnRemoteRequest(MessageParcel &data, Message { int len = data.ReadInt32(); if (len < 0) { - ZLOGW("len=%d invalid after ipc", len); + ZLOGW("len %d invalid after ipc", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write delete failed."); return -1; @@ -631,7 +629,6 @@ int32_t KvStoreImplStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessagePa { int32_t type = data.ReadInt32(); if (type < 0) { - ZLOGW("type=%d invalid after ipc", type); return -1; } SubscribeType subscribeType = static_cast(type); @@ -655,7 +652,6 @@ int32_t KvStoreImplStub::UnSubscribeKvStoreOnRemote(MessageParcel &data, Message { int32_t type = data.ReadInt32(); if (type < 0) { - ZLOGW("type=%d invalid after ipc", type); return -1; } SubscribeType subscribeType = static_cast(type); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp old mode 100755 new mode 100644 index 8e126f6c2..068c6a147 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp @@ -36,7 +36,7 @@ KvStoreDataServiceProxy::KvStoreDataServiceProxy(const sptr &impl Status KvStoreDataServiceProxy::GetKvStore(const Options &options, const AppId &appId, const StoreId &storeId, std::function)> callback) { - ZLOGI("appId=%s storeId=%s", appId.appId.c_str(), storeId.storeId.c_str()); + ZLOGI("%s %s", appId.appId.c_str(), storeId.storeId.c_str()); MessageParcel data; MessageParcel reply; @@ -86,7 +86,7 @@ Status KvStoreDataServiceProxy::GetKvStore(const Options &options, const AppId & Status KvStoreDataServiceProxy::GetSingleKvStore(const Options &options, const AppId &appId, const StoreId &storeId, std::function)> callback) { - ZLOGI("appId=%s storeId=%s", appId.appId.c_str(), storeId.storeId.c_str()); + ZLOGI("%s %s", appId.appId.c_str(), storeId.storeId.c_str()); MessageParcel data; MessageParcel reply; if (!data.WriteInterfaceToken(KvStoreDataServiceProxy::GetDescriptor())) { @@ -121,7 +121,7 @@ Status KvStoreDataServiceProxy::GetSingleKvStore(const Options &options, const A MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETSINGLEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -154,7 +154,7 @@ void KvStoreDataServiceProxy::GetAllKvStoreId(const AppId &appId, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETALLKVSTOREID, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); callback(Status::IPC_ERROR, storeIds); return; } @@ -183,7 +183,7 @@ Status KvStoreDataServiceProxy::CloseKvStore(const AppId &appId, const StoreId & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -205,7 +205,7 @@ Status KvStoreDataServiceProxy::CloseAllKvStore(const AppId &appId) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSEALLKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -227,7 +227,7 @@ Status KvStoreDataServiceProxy::DeleteKvStore(const AppId &appId, const StoreId MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -249,7 +249,7 @@ Status KvStoreDataServiceProxy::DeleteAllKvStore(const AppId &appId) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEALLKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -273,14 +273,13 @@ Status KvStoreDataServiceProxy::RegisterClientDeathObserver(const AppId &appId, return Status::IPC_ERROR; } } else { - ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REGISTERCLIENTDEATHOBSERVER, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode=%d", error); + ZLOGW("failed during IPC. errCode %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -297,7 +296,7 @@ Status KvStoreDataServiceProxy::GetLocalDevice(OHOS::DistributedKv::DeviceInfo & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETLOCALDEVICE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -322,7 +321,7 @@ Status KvStoreDataServiceProxy::GetDeviceList(std::vector &deviceInf MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETDEVICELIST, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -354,18 +353,16 @@ Status KvStoreDataServiceProxy::StartWatchDeviceChange(sptrAsObject().GetRefPtr())) { - ZLOGW("WriteRemoteObject observer failed."); return Status::IPC_ERROR; } } else { - ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageParcel reply; MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTWATCHDEVICECHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -380,18 +377,16 @@ Status KvStoreDataServiceProxy::StopWatchDeviceChange(sptrAsObject().GetRefPtr())) { - ZLOGW("WriteRemoteObject observer failed."); return Status::IPC_ERROR; } } else { - ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageParcel reply; MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STOPWATCHDEVICECHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -410,7 +405,7 @@ sptr KvStoreDataServiceProxy::GetRdbService() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GET_RDB_SERVICE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned=%{public}d", error); + ZLOGE("SendRequest returned %{public}d", error); return nullptr; } auto remoteObject = reply.ReadRemoteObject(); @@ -449,7 +444,6 @@ int32_t KvStoreDataServiceStub::GetKvStoreOnRemote(MessageParcel &data, MessageP Status status = GetKvStore(options, appId, storeId, [&proxyTmp](sptr proxy) { proxyTmp = std::move(proxy); }); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } if (proxyTmp == nullptr) { @@ -475,12 +469,10 @@ int32_t KvStoreDataServiceStub::GetAllKvStoreIdOnRemote(MessageParcel &data, Mes }); if (!reply.WriteStringVector(storeIdList)) { - ZLOGW("write storeIdList failed."); return -1; } if (!reply.WriteInt32(static_cast(statusTmp))) { - ZLOGW("write statusTmp failed."); return -1; } return 0; @@ -491,18 +483,15 @@ int32_t KvStoreDataServiceStub::GetDeviceListOnRemote(MessageParcel &data, Messa DeviceFilterStrategy strategy = static_cast(data.ReadInt32()); Status status = GetDeviceList(infos, strategy); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } if (status == Status::SUCCESS) { if (!reply.WriteInt32(infos.size())) { - ZLOGW("write infos failed."); return -1; } for (DeviceInfo const &info : infos) { if (!reply.WriteString(info.deviceId) || !reply.WriteString(info.deviceName) || !reply.WriteString(info.deviceType)) { - ZLOGW("write info failed."); return -1; } } @@ -523,7 +512,6 @@ int32_t KvStoreDataServiceStub::StartWatchDeviceChangeOnRemote(MessageParcel &da sptr observerProxy = iface_cast(remote); Status status = StartWatchDeviceChange(std::move(observerProxy), strategy); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -541,7 +529,6 @@ int32_t KvStoreDataServiceStub::StopWatchDeviceChangeOnRemote(MessageParcel &dat sptr observerProxy = iface_cast(remote); Status status = StopWatchDeviceChange(std::move(observerProxy)); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -575,12 +562,10 @@ int32_t KvStoreDataServiceStub::GetSingleKvStoreOnRemote(MessageParcel &data, Me Status status = GetSingleKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } if (status == Status::SUCCESS && proxyTmp != nullptr) { if (!reply.WriteRemoteObject(proxyTmp->AsObject().GetRefPtr())) { - ZLOGW("WriteRemoteObject proxyTmp failed."); return -1; } } @@ -593,7 +578,6 @@ int32_t KvStoreDataServiceStub::CloseKvStoreOnRemote(MessageParcel &data, Messag StoreId storeId = { Constant::TrimCopy(data.ReadString())}; Status status = CloseKvStore(appId, storeId); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -604,7 +588,6 @@ int32_t KvStoreDataServiceStub::CloseAllKvStoreOnRemote(MessageParcel &data, Mes AppId appId = { Constant::TrimCopy(data.ReadString())}; Status status = CloseAllKvStore(appId); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -616,7 +599,6 @@ int32_t KvStoreDataServiceStub::DeleteKvStoreOnRemote(MessageParcel &data, Messa StoreId storeId = { Constant::TrimCopy(data.ReadString())}; Status status = DeleteKvStore(appId, storeId); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -627,7 +609,6 @@ int32_t KvStoreDataServiceStub::DeleteAllKvStoreOnRemote(MessageParcel &data, Me AppId appId = { Constant::TrimCopy(data.ReadString())}; Status status = DeleteAllKvStore(appId); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -638,12 +619,10 @@ int32_t KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote(MessageParce AppId appId = { Constant::TrimCopy(data.ReadString())}; sptr kvStoreClientDeathObserverProxy = data.ReadRemoteObject(); if (kvStoreClientDeathObserverProxy == nullptr) { - ZLOGW("kvStoreClientDeathObserverProxy is nullptr."); return -1; } Status status = RegisterClientDeathObserver(appId, std::move(kvStoreClientDeathObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -655,7 +634,6 @@ int32_t KvStoreDataServiceStub::GetLocalDeviceOnRemote(MessageParcel &data, Mess Status status = GetLocalDevice(info); if (!reply.WriteInt32(static_cast(status)) || !reply.WriteString(info.deviceId) || !reply.WriteString(info.deviceName) || !reply.WriteString(info.deviceType)) { - ZLOGW("write failed."); return -1; } return 0; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp index e748ebe46..1ed10b7cc 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_observer.cpp @@ -125,7 +125,7 @@ void KvStoreObserverProxy::OnChange(const ChangeNotification &changeNotification MessageOption mo { MessageOption::TF_WAIT_TIME }; int error = Remote()->SendRequest(ONCHANGE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest failed, error=%d", error); + ZLOGE("SendRequest failed, error %d", error); } } @@ -154,7 +154,7 @@ bool ReadListFromBuf(MessageParcel &data, std::vector &entries) { int len = data.ReadInt32(); if (len < 0) { - ZLOGE("read onChangeLen failed len=%d", len); + ZLOGE("read onChangeLen failed len %d", len); return false; } int bufferSize = data.ReadInt32(); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp old mode 100755 new mode 100644 index d366654d3..72dd7171e --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp @@ -79,13 +79,12 @@ bool KvStoreResultSetProxy::Move(int offset) } bool ret = data.WriteInt32(offset); if (!ret) { - ZLOGE("write offset failed"); return ret; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(MOVE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d, code=%d", error, MOVE); + ZLOGW("SendRequest returned %d, code=%d", error, MOVE); return false; } return reply.ReadBool(); @@ -100,13 +99,12 @@ bool KvStoreResultSetProxy::MoveToPosition(int position) } bool ret = data.WriteInt32(position); if (!ret) { - ZLOGE("write position failed"); return ret; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(MOVETOPOSITION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d, code=%d", error, MOVETOPOSITION); + ZLOGW("SendRequest returned %d, code=%d", error, MOVETOPOSITION); return false; } return reply.ReadBool(); @@ -149,13 +147,13 @@ Status KvStoreResultSetProxy::GetEntry(Entry &entry) ZLOGI("start"); int32_t error = Remote()->SendRequest(GETENTRY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not successful, error=%d", static_cast(status)); + ZLOGW("status not success(%d)", static_cast(status)); return status; } sptr valueTmp = reply.ReadParcelable(); @@ -175,7 +173,7 @@ int KvStoreResultSetProxy::SendRequest(uint32_t code) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(code, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d, code=%d", error, code); + ZLOGW("SendRequest returned %d, code=%d", error, code); return -1; } return reply.ReadInt32(); @@ -191,7 +189,7 @@ bool KvStoreResultSetProxy::SendRequestRetBool(uint32_t code) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(code, data, reply, mo); if (error != 0) { - ZLOGW("SendRequestRetBool returned=%d, code=%d", error, code); + ZLOGW("SendRequestRetBool returned %d, code=%d", error, code); return false; } return reply.ReadBool(); @@ -319,7 +317,7 @@ int KvStoreResultSetStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me return GetEntryOnRemote(reply); } default: { - ZLOGW("OnRemoteRequest default=%d", code); + ZLOGW("OnRemoteRequest default %d", code); MessageOption mo { MessageOption::TF_SYNC }; return IPCObjectStub::OnRemoteRequest(code, data, reply, mo); } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp old mode 100755 new mode 100644 index 522d613f9..396b2eae5 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp @@ -52,7 +52,7 @@ Status SingleKvStoreProxy::Put(const Key &key, const Value &value) } int error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed with error code=%d", error); + ZLOGW("SendRequest failed with error code %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -75,7 +75,7 @@ Status SingleKvStoreProxy::Put(const Key &key, const Value &value) // rawdata: keySize | key | ValueSize | value int32_t error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -96,7 +96,7 @@ Status SingleKvStoreProxy::Delete(const Key &key) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -120,12 +120,12 @@ Status SingleKvStoreProxy::Get(const Key &key, Value &value) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not successful, error=%d", static_cast(status)); + ZLOGW("status not success(%d)", static_cast(status)); return status; } @@ -165,7 +165,6 @@ Status SingleKvStoreProxy::SubscribeKvStore(const SubscribeType subscribeType, return Status::IPC_ERROR; } if (observer == nullptr) { - ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } if (!data.WriteInt32(static_cast(subscribeType)) || @@ -176,7 +175,7 @@ Status SingleKvStoreProxy::SubscribeKvStore(const SubscribeType subscribeType, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -192,7 +191,6 @@ Status SingleKvStoreProxy::UnSubscribeKvStore(const SubscribeType subscribeType, return Status::IPC_ERROR; } if (observer == nullptr) { - ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } if (!data.WriteInt32(static_cast(subscribeType)) || @@ -204,7 +202,7 @@ Status SingleKvStoreProxy::UnSubscribeKvStore(const SubscribeType subscribeType, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -225,13 +223,12 @@ Status SingleKvStoreProxy::GetEntries(const Key &prefixKey, std::vector & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETENTRIES, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -252,7 +249,7 @@ Status SingleKvStoreProxy::GetEntries(const Key &prefixKey, std::vector & // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, bufferSize); return Status::IPC_ERROR; } @@ -292,13 +289,12 @@ Status SingleKvStoreProxy::GetEntriesWithQuery(const std::string &query, std::ve MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETENTRIESWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -319,7 +315,7 @@ Status SingleKvStoreProxy::GetEntriesWithQuery(const std::string &query, std::ve // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, bufferSize); return Status::IPC_ERROR; } @@ -356,19 +352,17 @@ void SingleKvStoreProxy::GetResultSet(const Key &prefixKey, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETRESULTSET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); callback(Status::IPC_ERROR, nullptr); return; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("ReadInt32 reply failed status=%d", status); callback(status, nullptr); return; } sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { - ZLOGW("ReadRemoteObject reply failed"); callback(status, nullptr); return; } @@ -394,19 +388,17 @@ void SingleKvStoreProxy::GetResultSetWithQuery(const std::string &query, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETRESULTSETWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); callback(Status::IPC_ERROR, nullptr); return; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("ReadInt32 reply failed status=%d", status); callback(status, nullptr); return; } sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { - ZLOGW("ReadRemoteObject reply failed"); callback(status, nullptr); return; } @@ -431,13 +423,12 @@ Status SingleKvStoreProxy::GetCountWithQuery(const std::string &query, int &resu MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETCOUNTWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -454,7 +445,6 @@ Status SingleKvStoreProxy::CloseResultSet(sptr resultSetPtr) return Status::IPC_ERROR; } if (resultSetPtr == nullptr) { - ZLOGW("resultSetPtr is nullptr"); return Status::INVALID_ARGUMENT; } @@ -465,7 +455,7 @@ Status SingleKvStoreProxy::CloseResultSet(sptr resultSetPtr) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSERESULTSET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -496,7 +486,7 @@ Status SingleKvStoreProxy::Sync(const std::vector &deviceIds, SyncM } int32_t error = Remote()->SendRequest(SYNC, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -527,7 +517,7 @@ Status SingleKvStoreProxy::Sync(const std::vector &deviceIds, SyncM MessageParcel reply; int32_t error = Remote()->SendRequest(SYNC_WITH_CONDITION, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned=%d", error); + ZLOGE("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -549,7 +539,7 @@ Status SingleKvStoreProxy::RemoveDeviceData(const std::string &device) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REMOVEDEVICEDATA, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -575,7 +565,7 @@ Status SingleKvStoreProxy::RegisterSyncCallback(sptr callb MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REGISTERSYNCCALLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -592,7 +582,7 @@ Status SingleKvStoreProxy::UnRegisterSyncCallback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNREGISTERSYNCCALLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -618,7 +608,6 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) int64_t bufferSize = 0; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { - ZLOGW("entry length is too long, entry.key=%d, entry.value=%d", item.key.Size(), item.value.Size()); return Status::INVALID_ARGUMENT; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -636,7 +625,6 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) } MessageOption mo { MessageOption::TF_SYNC }; if (Remote()->SendRequest(PUTBATCH, data, reply, mo) != 0) { - ZLOGW("Remote() SendRequest failed."); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -667,7 +655,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUTBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -701,7 +689,7 @@ Status SingleKvStoreProxy::DeleteBatch(const std::vector &keys) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -717,7 +705,7 @@ Status SingleKvStoreProxy::StartTransaction() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTTRANSACTION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -733,7 +721,7 @@ Status SingleKvStoreProxy::Commit() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(COMMIT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -749,7 +737,7 @@ Status SingleKvStoreProxy::Rollback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(ROLLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned=%d", error); + ZLOGW("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -778,12 +766,12 @@ Status SingleKvStoreProxy::Control(KvControlCmd cmd, const KvParam &inputParam, MessageOption mo{MessageOption::TF_SYNC}; int32_t error = Remote()->SendRequest(CONTROL, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not successful, error=%d", static_cast(status)); + ZLOGW("status not success(%d)", static_cast(status)); return status; } @@ -894,7 +882,7 @@ Status SingleKvStoreProxy::Subscribe(const std::vector &deviceIds, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned=%d", error); + ZLOGE("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -924,7 +912,7 @@ Status SingleKvStoreProxy::UnSubscribe(const std::vector &deviceIds MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned=%d", error); + ZLOGE("SendRequest returned %d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -979,7 +967,6 @@ int SingleKvStoreStub::PutOnRemote(MessageParcel &data, MessageParcel &reply) } Status status = Put(key, value); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status error"); return -1; } return 0; @@ -996,7 +983,6 @@ int SingleKvStoreStub::DeleteOnRemote(MessageParcel &data, MessageParcel &reply) } Status status = Delete(*key); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status error"); return -1; } return 0; @@ -1057,7 +1043,6 @@ int SingleKvStoreStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessageParc SubscribeType subscribeType = static_cast(data.ReadInt32()); sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { - ZLOGW("ReadRemoteObject reply failed"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { return -1; } @@ -1067,7 +1052,6 @@ int SingleKvStoreStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessageParc Status status = SubscribeKvStore(subscribeType, std::move(kvStoreObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status error"); return -1; } return 0; @@ -1086,7 +1070,6 @@ int SingleKvStoreStub::UnSubscribeKvStoreOnRemote(MessageParcel &data, MessagePa sptr kvStoreObserverProxy = iface_cast(remote); Status status = UnSubscribeKvStore(subscribeType, std::move(kvStoreObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status error"); return -1; } return 0; @@ -1135,7 +1118,6 @@ int SingleKvStoreStub::GetEntriesOnRemote(MessageParcel &data, MessageParcel &re std::vector entries; Status status = GetEntries(*keyPrefix, entries); if (status != Status::SUCCESS) { - ZLOGW("write status error"); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1148,7 +1130,7 @@ int SingleKvStoreStub::GetEntriesOnRemote(MessageParcel &data, MessageParcel &re } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -1194,7 +1176,6 @@ int SingleKvStoreStub::GetEntriesWithQueryOnRemote(MessageParcel &data, MessageP std::vector entries; Status status = GetEntriesWithQuery(query, entries); if (status != Status::SUCCESS) { - ZLOGW("write status error"); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1207,7 +1188,7 @@ int SingleKvStoreStub::GetEntriesWithQueryOnRemote(MessageParcel &data, MessageP } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -1248,7 +1229,7 @@ int SingleKvStoreStub::SyncOnRemote(MessageParcel &data, MessageParcel &reply) { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGW("SYNC list=%zu", devices.size()); + ZLOGW("SYNC list:%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write sync status fail"); return -1; @@ -1332,7 +1313,7 @@ int SingleKvStoreStub::PutBatchOnRemote(MessageParcel &data, MessageParcel &repl } int len = data.ReadInt32(); if (len < 0) { - ZLOGW("invalid status. len=%d", len); + ZLOGW("invalid status. len %d", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write to parcel failed."); return -1; @@ -1399,7 +1380,7 @@ int SingleKvStoreStub::DeleteBatchOnRemote(MessageParcel &data, MessageParcel &r { int len = data.ReadInt32(); if (len < 0) { - ZLOGW("len=%d invalid after ipc", len); + ZLOGW("len %d invalid after ipc", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write delete failed."); return -1; @@ -1466,7 +1447,7 @@ int SingleKvStoreStub::OnSecurityLevelRequest(MessageParcel &data, MessageParcel SecurityLevel securityLevel = SecurityLevel::NO_LABEL; auto status = GetSecurityLevel(securityLevel); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("Get SecurityLevel ipc error."); + ZLOGW("Get SecurityLevel ipc failed."); return -1; } if (!reply.WriteInt32(static_cast(securityLevel))) { @@ -1504,7 +1485,6 @@ int SingleKvStoreStub::GetCountWithQueryOnRemote(MessageParcel &data, MessagePar int result; Status status = GetCountWithQuery(query, result); if (status != Status::SUCCESS) { - ZLOGW("get status failed."); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1521,7 +1501,6 @@ int SingleKvStoreStub::CloseResultSetOnRemote(MessageParcel &data, MessageParcel { sptr obj = data.ReadRemoteObject(); if (obj == nullptr) { - ZLOGW("ReadRemoteObject failed."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { return -1; } @@ -1530,7 +1509,6 @@ int SingleKvStoreStub::CloseResultSetOnRemote(MessageParcel &data, MessageParcel sptr kvStoreResultSetProxy = iface_cast(obj); Status status = CloseResultSet(kvStoreResultSetProxy); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write status failed."); return -1; } return 0; @@ -1627,7 +1605,7 @@ int SingleKvStoreStub::OnSyncRequest(MessageParcel &data, MessageParcel &reply) { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGI("SYNC list=%zu", devices.size()); + ZLOGI("SYNC list:%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; @@ -1667,7 +1645,7 @@ int SingleKvStoreStub::OnSubscribeRequest(MessageParcel &data, MessageParcel &re { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGE("SYNC list=%zu", devices.size()); + ZLOGE("SYNC list:%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; @@ -1688,7 +1666,7 @@ int SingleKvStoreStub::OnUnSubscribeRequest(MessageParcel &data, MessageParcel & { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGE("SYNC list=%zu", devices.size()); + ZLOGE("SYNC list:%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp old mode 100755 new mode 100644 index 93f25b730..9674351eb --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp @@ -72,7 +72,7 @@ void KvStoreSnapshotImplProxy::GetEntries(const Key &prefixKey, const Key &nextK Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success, which = %d", static_cast(status)); + ZLOGW("status not success, which is %d", static_cast(status)); callback(status, entries, Key()); return; } @@ -94,7 +94,7 @@ void KvStoreSnapshotImplProxy::GetEntries(const Key &prefixKey, const Key &nextK // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, bufferSize); callback(Status::IPC_ERROR, entries, Key()); return; @@ -128,17 +128,14 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, } std::vector keyList; if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { - ZLOGW("SetMaxCapacity failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } if (!data.WriteParcelable(&prefixKey)) { - ZLOGW("prefixKey WriteParcelable failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } if (!data.WriteParcelable(&nextKey)) { - ZLOGW("nextKey WriteParcelable failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } @@ -152,7 +149,7 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not successful, error = %d", static_cast(status)); + ZLOGW("status not success, which is %d", static_cast(status)); callback(status, keyList, Key()); return; } @@ -174,7 +171,7 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyKeyCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyKeyCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyKeyCount, bufferSize); + ZLOGW("replyKeyCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyKeyCount, bufferSize); callback(Status::IPC_ERROR, keyList, Key()); return; } @@ -204,11 +201,9 @@ Status KvStoreSnapshotImplProxy::Get(const Key &key, Value &value) return Status::IPC_ERROR; } if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { - ZLOGW("SetMaxCapacity failed"); return Status::IPC_ERROR; } if (!data.WriteParcelable(&key)) { - ZLOGW("key WriteParcelable failed"); return Status::IPC_ERROR; } @@ -216,12 +211,12 @@ Status KvStoreSnapshotImplProxy::Get(const Key &key, Value &value) ZLOGI("start"); int32_t error = Remote()->SendRequest(GET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error = %d", error); + ZLOGW("SendRequest failed, error is %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not successful, error=%d", static_cast(status)); + ZLOGW("status not success(%d)", static_cast(status)); return status; } @@ -339,7 +334,7 @@ int32_t KvStoreSnapshotImplStub::GetEntriesOnRemote(MessageParcel &data, Message } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -387,7 +382,6 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce if (keyPrefix == nullptr) { ZLOGW("keyPrefix is null"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("keyPrefix WriteInt32 error"); return -1; } if (!reply.WriteParcelable(nullptr)) { @@ -398,7 +392,6 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce if (nextKey == nullptr) { ZLOGW("nextKey is null. return."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("nextKey WriteInt32 error"); return -1; } if (!reply.WriteParcelable(nullptr)) { @@ -420,7 +413,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce } ZLOGI("getting large key set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR)) || !reply.WriteParcelable(&nxtKey)) { ZLOGW("write status failed."); @@ -467,7 +460,6 @@ int32_t KvStoreSnapshotImplStub::GetRemote(MessageParcel &data, MessageParcel &r if (key == nullptr) { ZLOGW("key is null"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("key WriteInt32 is null"); return -1; } if (!reply.WriteInt32(0)) { @@ -527,7 +519,6 @@ int32_t KvStoreSnapshotImplStub::OnRemoteRequest(uint32_t code, MessageParcel &d return -1; } if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { - ZLOGW("reply SetMaxCapacity failed."); return -1; } switch (code) { @@ -542,7 +533,6 @@ int32_t KvStoreSnapshotImplStub::OnRemoteRequest(uint32_t code, MessageParcel &d } default: if (!reply.WriteInt32((int32_t)Status::ERROR)) { - ZLOGW("reply WriteInt32 status failed."); return -1; } return 0; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp index bcde27f73..863547b13 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_sync_callback.cpp @@ -60,7 +60,7 @@ void KvStoreSyncCallbackProxy::SyncCompleted(const std::map MessageOption mo { MessageOption::TF_SYNC }; int error = Remote()->SendRequest(SYNCCOMPLETED, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error=%d", error); + ZLOGW("SendRequest failed, error %d", error); } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp index d0227968a..2f084d300 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp @@ -57,7 +57,6 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, std::vector &output) bool ITypesUtil::Marshalling(const Entry &entry, MessageParcel &data) { if (!Marshalling(entry.key, data)) { - ZLOGW("Marshalling failed"); return false; } return Marshalling(entry.value, data); @@ -66,7 +65,6 @@ bool ITypesUtil::Marshalling(const Entry &entry, MessageParcel &data) bool ITypesUtil::Unmarshalling(MessageParcel &data, Entry &output) { if (!Unmarshalling(data, output.key)) { - ZLOGW("Unmarshalling failed"); return false; } return Unmarshalling(data, output.value); @@ -75,11 +73,9 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, Entry &output) bool ITypesUtil::Marshalling(const DeviceInfo &entry, MessageParcel &data) { if (!data.WriteString(entry.deviceId)) { - ZLOGW("write deviceId failed"); return false; } if (!data.WriteString(entry.deviceName)) { - ZLOGW("write deviceName failed"); return false; } return data.WriteString(entry.deviceType); @@ -88,11 +84,9 @@ bool ITypesUtil::Marshalling(const DeviceInfo &entry, MessageParcel &data) bool ITypesUtil::Unmarshalling(MessageParcel &data, DeviceInfo &output) { if (!data.ReadString(output.deviceId)) { - ZLOGW("read deviceId failed"); return false; } if (!data.ReadString(output.deviceName)) { - ZLOGW("read deviceName failed"); return false; } return data.ReadString(output.deviceType); @@ -110,17 +104,14 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, std::vector &out bool ITypesUtil::Marshalling(const ChangeNotification ¬ification, MessageParcel &parcel) { if (!Marshalling(notification.GetInsertEntries(), parcel)) { - ZLOGW("GetInsertEntries failed"); return false; } if (!Marshalling(notification.GetUpdateEntries(), parcel)) { - ZLOGW("GetUpdateEntries failed"); return false; } if (!Marshalling(notification.GetDeleteEntries(), parcel)) { - ZLOGW("GetDeleteEntries failed"); return false; } if (!parcel.WriteString(notification.GetDeviceId())) { @@ -135,17 +126,14 @@ bool ITypesUtil::Unmarshalling(MessageParcel &parcel, ChangeNotification &output { std::vector insertEntries; if (!Unmarshalling(parcel, insertEntries)) { - ZLOGW("insertEntries failed"); return false; } std::vector updateEntries; if (!Unmarshalling(parcel, updateEntries)) { - ZLOGW("updateEntries failed"); return false; } std::vector deleteEntries; if (!Unmarshalling(parcel, deleteEntries)) { - ZLOGW("deleteEntries failed"); return false; } std::string deviceId; @@ -380,7 +368,6 @@ int64_t ITypesUtil::GetTotalSize(const std::vector &entries) int64_t bufferSize = 1; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { - ZLOGW("entry length too long key=%d, value=%d", item.key.Size(), item.value.Size()); return -bufferSize; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -392,7 +379,6 @@ int64_t ITypesUtil::GetTotalSize(const std::vector &entries) int64_t bufferSize = 1; for (const auto &item : entries) { if (item.Size() > Constant::MAX_KEY_LENGTH) { - ZLOGW("entry length too long, size=%d", item.Size()); return -bufferSize; } bufferSize += item.RawSize(); @@ -405,25 +391,21 @@ bool ITypesUtil::ReadVector(Parcel &parcel, std::vector &val, bool (Parcel::* { int32_t len = parcel.ReadInt32(); if (len < 0) { - ZLOGW("read parcel error len=%d", len); return false; } size_t readAbleSize = parcel.GetReadableBytes(); size_t size = static_cast(len); if ((size > readAbleSize) || (size > val.max_size())) { - ZLOGW("parcel size too long, size=%d", size); return false; } val.resize(size); if (val.size() < size) { - ZLOGW("size too long, size=%d", size); return false; } for (auto &v : val) { if (!(parcel.*read)(v)) { - ZLOGW("parcel read value error"); return false; } } @@ -435,18 +417,15 @@ template bool ITypesUtil::WriteVector(Parcel &parcel, const std::vector &val, bool (Parcel::*writer)(const T &)) { if (val.size() > INT_MAX) { - ZLOGW("value size too long, size=%d", val.size()); return false; } if (!parcel.WriteInt32(static_cast(val.size()))) { - ZLOGW("parcel write size error"); return false; } for (auto &v : val) { if (!(parcel.*writer)(v)) { - ZLOGW("parcel write value error"); return false; } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp old mode 100755 new mode 100644 index 3840e8cbe..00192e53c --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp @@ -63,7 +63,7 @@ Status KvStoreClient::GetKvStoreSnapshot(std::shared_ptr observ }; kvStoreProxy_->GetKvStoreSnapshot(kvStoreObserverClient, snapshotCallbackFunction); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error=%d.", static_cast(statusTmp)); + ZLOGE("return error: %d.", static_cast(statusTmp)); return statusTmp; } @@ -95,13 +95,13 @@ Status KvStoreClient::ReleaseKvStoreSnapshot(std::shared_ptr &s sptr snapshotProxyTmp = kvStoreSnapshotClient->GetkvStoreSnapshotProxy(); Status status = kvStoreProxy_->ReleaseKvStoreSnapshot(std::move(snapshotProxyTmp)); snapshot = nullptr; - ZLOGI("return=%d.", static_cast(status)); + ZLOGI("return: %d.", static_cast(status)); return status; } Status KvStoreClient::Put(const Key &key, const Value &value) { - ZLOGD("key=%zu value=%zu.", key.Size(), value.Size()); + ZLOGD("key: %zu value: %zu.", key.Size(), value.Size()); DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); std::vector keyData = Constant::TrimCopy>(key.Data()); @@ -120,7 +120,7 @@ Status KvStoreClient::Put(const Key &key, const Value &value) Status KvStoreClient::PutBatch(const std::vector &entries) { - ZLOGI("entry size=%zu", entries.size()); + ZLOGI("entry size: %zu", entries.size()); DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); if (entries.size() > Constant::MAX_BATCH_SIZE) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client_death_observer.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client_death_observer.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_observer_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_observer_client.cpp old mode 100755 new mode 100644 diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp old mode 100755 new mode 100644 index 25a7a3a69..61c4707aa --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp @@ -17,14 +17,11 @@ #include "kvstore_resultset_client.h" #include "dds_trace.h" -#include "log_print.h" namespace OHOS::DistributedKv { KvStoreResultSetClient::KvStoreResultSetClient(sptr kvStoreProxy) :kvStoreResultSetProxy_(kvStoreProxy) -{ - ZLOGI("constructor"); -} +{} int KvStoreResultSetClient::GetCount() const { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp old mode 100755 new mode 100644 index 4a51ee120..c0f239c76 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp @@ -80,7 +80,6 @@ sptr KvStoreServiceDeathNotifier::GetDistributedKvDataServi void KvStoreServiceDeathNotifier::RegisterClientDeathObserver() { if (kvDataServiceProxy_ == nullptr) { - ZLOGE("initialize proxy failed."); return; } if (clientDeathObserverPtr_ == nullptr) { @@ -98,9 +97,9 @@ void KvStoreServiceDeathNotifier::AddServiceDeathWatcher(std::shared_ptr lg(watchMutex_); auto ret = serviceDeathWatchers_.insert(watcher); if (ret.second) { - ZLOGI("success set size=%zu", serviceDeathWatchers_.size()); + ZLOGI("success set size: %zu", serviceDeathWatchers_.size()); } else { - ZLOGE("failed set size=%zu", serviceDeathWatchers_.size()); + ZLOGE("failed set size: %zu", serviceDeathWatchers_.size()); } } @@ -110,9 +109,9 @@ void KvStoreServiceDeathNotifier::RemoveServiceDeathWatcher(std::shared_ptr lg(watchMutex_); kvDataServiceProxy_ = nullptr; - ZLOGI("watcher set size=%zu", serviceDeathWatchers_.size()); + ZLOGI("watcher set size: %zu", serviceDeathWatchers_.size()); for (const auto &watcher : serviceDeathWatchers_) { std::thread th = std::thread([watcher]() { watcher->OnRemoteDied(); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp index ce9b7448b..b20d66156 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp @@ -84,7 +84,6 @@ Status KvStoreSnapshotClient::GetEntries(const Key &prefixKey, std::vector &en [&status, &entries, &startKey](Status stat, auto &result, Key next) { status = stat; if (stat != Status::SUCCESS) { - ZLOGE("status error=%d.", status); return; } startKey = result.empty() ? "" : next; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp old mode 100755 new mode 100644 index 13a74fcef..028362ba5 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp @@ -41,7 +41,7 @@ void KvStoreSyncCallbackClient::AddSyncCallback(const std::shared_ptr kvStoreProxy, const std::string &storeId) : kvStoreProxy_(kvStoreProxy), storeId_(storeId), syncCallbackClient_(new KvStoreSyncCallbackClient()), syncObserver_(std::make_shared()) -{ - ZLOGI("constructor."); -} +{} SingleKvStoreClient::~SingleKvStoreClient() { - ZLOGI("destructor."); kvStoreProxy_->UnRegisterSyncCallback(); syncObserver_->Clean(); } @@ -91,7 +88,7 @@ Status SingleKvStoreClient::GetResultSet(const Key &prefixKey, std::shared_ptrGetResultSet(prefixKey, callFun); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error=%d.", static_cast(statusTmp)); + ZLOGE("return error: %d.", static_cast(statusTmp)); return statusTmp; } @@ -123,7 +120,7 @@ Status SingleKvStoreClient::GetResultSetWithQuery(const std::string &query, }; kvStoreProxy_->GetResultSetWithQuery(query, callFun); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error=%d.", static_cast(statusTmp)); + ZLOGE("return error: %d.", static_cast(statusTmp)); return statusTmp; } @@ -229,7 +226,7 @@ Status SingleKvStoreClient::Put(const Key &key, const Value &value) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); - ZLOGI("key=%zu value=%zu.", key.Size(), value.Size()); + ZLOGI("key: %zu value: %zu.", key.Size(), value.Size()); std::vector keyData = Constant::TrimCopy>(key.Data()); if (keyData.size() == 0 || keyData.size() > Constant::MAX_KEY_LENGTH || value.Size() > Constant::MAX_VALUE_LENGTH) { @@ -351,7 +348,7 @@ Status SingleKvStoreClient::PutBatch(const std::vector &entries) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); - ZLOGI("entry size=%zu", entries.size()); + ZLOGI("entry size: %zu", entries.size()); if (entries.size() > Constant::MAX_BATCH_SIZE) { ZLOGE("batch size must less than 128."); return Status::INVALID_ARGUMENT; @@ -425,14 +422,12 @@ Status SingleKvStoreClient::GetSyncParam(KvSyncParam &syncParam) KvParam output; Status ret = Control(KvControlCmd::GET_SYNC_PARAM, inputEmpty, output); if (ret != Status::SUCCESS) { - ZLOGE("ret error=%d.", ret); return ret; } if (output.Size() == sizeof(uint32_t)) { syncParam.allowedDelayMs = TransferByteArrayToType(output.Data()); return Status::SUCCESS; } - ZLOGE("output size error."); return Status::ERROR; } diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp index a1a9c76cf..1be079979 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp @@ -43,7 +43,7 @@ static sptr GetDistributedDataManager() std::this_thread::sleep_for(std::chrono::seconds(RdbManagerImpl::RETRY_INTERVAL)); continue; } - ZLOGI("get distributed data manager successful"); + ZLOGI("get distributed data manager success"); return iface_cast(remoteObject); } @@ -59,7 +59,7 @@ static void LinkToDeath(const sptr& remote) if (!remote->AddDeathRecipient(deathRecipient)) { ZLOGE("add death recipient failed"); } - ZLOGE("successful"); + ZLOGE("success"); } RdbManagerImpl::RdbManagerImpl() @@ -104,7 +104,6 @@ std::shared_ptr RdbManagerImpl::GetRdbService(const RdbSyncerParam& } auto service = GetRdbService(); if (service == nullptr) { - ZLOGE("get rdb service is nullptr"); return nullptr; } if (((RdbServiceProxy *)service.GetRefPtr())->InitNotifier(param) != RDB_OK) { @@ -129,12 +128,10 @@ void RdbManagerImpl::OnRemoteDied() param.bundleName_ = bundleName_; auto service = GetRdbService(param); if (service == nullptr) { - ZLOGI("rdb service alreadly dead"); return; } proxy = std::static_pointer_cast(service); if (proxy == nullptr) { - ZLOGI("rdb service proxy alreadly dead"); return; } ZLOGI("restore observer"); diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp index 072ac16e4..dba5a48a5 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp @@ -44,7 +44,6 @@ int32_t RdbNotifierProxy::OnComplete(uint32_t seqNum, const SyncResult &result) return RDB_ERROR; } if (!DistributedKv::ITypesUtil::Marshalling(result, data)) { - ZLOGE("marshalling result and data failed"); return RDB_ERROR; } @@ -110,7 +109,6 @@ int RdbNotifierStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message { ZLOGI("code=%{public}u", code); if (!CheckInterfaceToken(data)) { - ZLOGE("CheckInterfaceToken data error."); return RDB_ERROR; } diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp index 009be07fd..899882932 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp @@ -36,7 +36,7 @@ void RdbServiceProxy::OnSyncComplete(uint32_t seqNum, const SyncResult &result) void RdbServiceProxy::OnDataChange(const std::string& storeName, const std::vector &devices) { - ZLOGI("storeName=%{public}s", storeName.c_str()); + ZLOGI("%{public}s", storeName.c_str()); observers_.ComputeIfPresent( storeName, [&devices] (const auto& key, const ObserverMapValue& value) { for (const auto& observer : value.first) { @@ -90,7 +90,7 @@ int32_t RdbServiceProxy::InitNotifier(const RdbSyncerParam& param) return RDB_ERROR; } - ZLOGI("successful"); + ZLOGI("success"); return RDB_OK; } @@ -165,10 +165,10 @@ int32_t RdbServiceProxy::DoSync(const RdbSyncerParam& param, const SyncOption &o { SyncResult result; if (DoSync(param, option, predicates, result) != RDB_OK) { - ZLOGE("dosync failed"); + ZLOGI("failed"); return RDB_ERROR; } - ZLOGI("successful"); + ZLOGI("success"); if (callback != nullptr) { callback(result); @@ -222,12 +222,12 @@ int32_t RdbServiceProxy::DoAsync(const RdbSyncerParam& param, const SyncOption & ZLOGI("num=%{public}u", num); if (DoAsync(param, num, option, predicates) != RDB_OK) { - ZLOGE("do async failed"); + ZLOGE("failed"); syncCallbacks_.Erase(num); return RDB_ERROR; } - ZLOGI("successful"); + ZLOGI("success"); return RDB_OK; } @@ -262,7 +262,6 @@ int32_t RdbServiceProxy::Sync(const RdbSyncerParam& param, const SyncOption &opt const RdbPredicates &predicates, const SyncCallback &callback) { if (option.isBlock) { - ZLOGI("option isBlock"); return DoSync(param, option, predicates, callback); } return DoAsync(param, option, predicates, callback); @@ -276,7 +275,7 @@ int32_t RdbServiceProxy::Subscribe(const RdbSyncerParam ¶m, const SubscribeO return RDB_ERROR; } if (DoSubscribe(param) != RDB_OK) { - ZLOGE("communicate to server failed"); + ZLOGI("communicate to server failed"); return RDB_ERROR; } observers_.Compute( diff --git a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp index 8d922e98c..d3f105d41 100644 --- a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp @@ -29,19 +29,19 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("createKVManager", JsKVManager::CreateKVManager) }; napi_status status = napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - ZLOGI("init createKVManager status=%{public}d", status); + ZLOGI("init createKVManager %{public}d", status); status = napi_set_named_property(env, exports, "FieldNode", JsFieldNode::Constructor(env)); - ZLOGI("init FieldNode status=%{public}d", status); + ZLOGI("init FieldNode %{public}d", status); status = napi_set_named_property(env, exports, "Schema", JsSchema::Constructor(env)); - ZLOGI("init Schema status=%{public}d", status); + ZLOGI("init Schema %{public}d", status); status = napi_set_named_property(env, exports, "Query", JsQuery::Constructor(env)); - ZLOGI("init Query status=%{public}d", status); + ZLOGI("init Query %{public}d", status); status = InitConstProperties(env, exports); - ZLOGI("init Enumerate Constants status=%{public}d", status); + ZLOGI("init Enumerate Constants %{public}d", status); return exports; } diff --git a/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp index ae7f74928..7034d5883 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp @@ -38,12 +38,10 @@ static std::string GetDeviceKey(const std::string& deviceId, const std::string& JsDeviceKVStore::JsDeviceKVStore(const std::string& storeId) : JsKVStore(storeId) { - ZLOGD("constructor"); } napi_value JsDeviceKVStore::Constructor(napi_env env) { - ZLOGD("JsDeviceKVStore::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("put", JsKVStore::Put), DECLARE_NAPI_FUNCTION("delete", JsKVStore::Delete), @@ -102,7 +100,7 @@ napi_value JsDeviceKVStore::Get(napi_env env, napi_callback_info info) OHOS::DistributedKv::Value value; auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Get(deviceKey, value); - ZLOGD("kvStore->Get return status=%{public}d", status); + ZLOGD("kvStore->Get return %{public}d", status); ctxt->value = JSUtil::Blob2VariantValue(value); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Get() failed!"); @@ -194,16 +192,16 @@ napi_value JsDeviceKVStore::GetEntries(napi_env env, napi_callback_info info) std::string deviceKey = GetDeviceKey(ctxt->va.deviceId, ctxt->va.keyPrefix); OHOS::DistributedKv::Key keyPrefix(deviceKey); status = kvStore->GetEntries(keyPrefix, ctxt->entries); - ZLOGD("kvStore->GetEntries() return status=%{public}d", status); + ZLOGD("kvStore->GetEntries() return %{public}d", status); } else if (ctxt->va.type == ArgsType::DEVICEID_QUERY) { auto query = ctxt->va.query->GetNative(); query.DeviceId(ctxt->va.deviceId); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetEntries() failed!"); @@ -252,16 +250,16 @@ napi_value JsDeviceKVStore::GetResultSet(napi_env env, napi_callback_info info) std::string deviceKey = GetDeviceKey(ctxt->va.deviceId, ctxt->va.keyPrefix); OHOS::DistributedKv::Key keyPrefix(deviceKey); status = kvStore->GetResultSet(keyPrefix, kvResultSet); - ZLOGD("kvStore->GetEntries() return status=%{public}d", status); + ZLOGD("kvStore->GetEntries() return %{public}d", status); } else if (ctxt->va.type == ArgsType::DEVICEID_QUERY) { auto query = ctxt->va.query->GetNative(); query.DeviceId(ctxt->va.deviceId); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetResultSet() failed!"); @@ -302,7 +300,7 @@ napi_value JsDeviceKVStore::CloseResultSet(napi_env env, napi_callback_info info auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->CloseResultSet(ctxt->resultSet->GetNative()); - ZLOGD("kvStore->CloseResultSet return status=%{public}d", status); + ZLOGD("kvStore->CloseResultSet return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->CloseResultSet failed!"); }; @@ -340,7 +338,7 @@ napi_value JsDeviceKVStore::GetResultSize(napi_env env, napi_callback_info info) query.DeviceId(ctxt->va.deviceId); } Status status = kvStore->GetCountWithQuery(query.ToString(), ctxt->resultSize); - ZLOGD("kvStore->GetCountWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetCountWithQuery() return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetCountWithQuery() failed!"); }; @@ -374,7 +372,7 @@ napi_value JsDeviceKVStore::RemoveDeviceData(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->RemoveDeviceData(ctxt->deviceId); - ZLOGD("kvStore->RemoveDeviceData return status=%{public}d", status); + ZLOGD("kvStore->RemoveDeviceData return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->RemoveDeviceData() failed!"); }; @@ -387,7 +385,6 @@ napi_value JsDeviceKVStore::RemoveDeviceData(napi_env env, napi_callback_info in */ napi_value JsDeviceKVStore::Sync(napi_env env, napi_callback_info info) { - ZLOGD("JsDeviceKVStore::Sync"); struct SyncContext : public ContextBase { std::vector deviceIdList; uint32_t mode = 0; @@ -407,7 +404,7 @@ napi_value JsDeviceKVStore::Sync(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Sync(ctxt->deviceIdList, static_cast(ctxt->mode)); - ZLOGD("kvStore->Sync return status=%{public}d!", status); + ZLOGD("kvStore->Sync return %{public}d!", status); NAPI_ASSERT(env, status == Status::SUCCESS, "kvStore->Sync() failed!"); return nullptr; } diff --git a/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp b/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp index d44e90c37..c18072280 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp @@ -41,7 +41,6 @@ std::map JsFieldNode::valueTypeToString_ = { JsFieldNode::JsFieldNode(const std::string& fName) : fieldName(fName) { - ZLOGD("constructor"); } std::string JsFieldNode::GetFieldName() @@ -64,7 +63,6 @@ JsFieldNode::json JsFieldNode::GetValueForJson() napi_value JsFieldNode::Constructor(napi_env env) { - ZLOGD("JsFieldNode::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("appendChild", JsFieldNode::AppendChild), DECLARE_NAPI_GETTER_SETTER("default", JsFieldNode::GetDefaultValue, JsFieldNode::SetDefaultValue), @@ -253,7 +251,6 @@ std::string JsFieldNode::ValueTypeToString(uint32_t type) // DistributedDB::FieldType auto it = valueTypeToString_.find(type); if (valueTypeToString_.find(type) != valueTypeToString_.end()) { - ZLOGD("find type is the last"); return it->second; } else { return std::string(); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp index 2966ee05c..8759ac81d 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp @@ -126,7 +126,7 @@ napi_value JsKVManager::GetKVStore(napi_env env, napi_callback_info info) StoreId storeId = { ctxt->storeId }; std::shared_ptr kvStore; Status status = kvm->kvDataManager_.GetSingleKvStore(ctxt->options, appId, storeId, kvStore); - ZLOGD("GetSingleKvStore return status=%{public}d", status); + ZLOGD("GetSingleKvStore return status:%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "KVManager->GetSingleKvStore() failed!"); ctxt->kvStore->SetNative(kvStore); @@ -172,7 +172,7 @@ napi_value JsKVManager::CloseKVStore(napi_env env, napi_callback_info info) AppId appId { ctxt->appId }; StoreId storeId { ctxt->storeId }; Status status = reinterpret_cast(ctxt->native)->kvDataManager_.CloseKvStore(appId, storeId); - ZLOGD("CloseKVStore return status=%{public}d", status); + ZLOGD("CloseKVStore return status:%{public}d", status); ctxt->status = ((status == Status::SUCCESS) || (status == Status::STORE_NOT_FOUND) || (status == Status::STORE_NOT_OPEN)) ? napi_ok @@ -209,7 +209,7 @@ napi_value JsKVManager::DeleteKVStore(napi_env env, napi_callback_info info) AppId appId { ctxt->appId }; StoreId storeId { ctxt->storeId }; Status status = reinterpret_cast(ctxt->native)->kvDataManager_.DeleteKvStore(appId, storeId); - ZLOGD("DeleteKvStore status=%{public}d", status); + ZLOGD("DeleteKvStore status:%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; }; return NapiQueue::AsyncWork(env, ctxt, std::string(__FUNCTION__), execute); @@ -242,26 +242,25 @@ napi_value JsKVManager::GetAllKVStoreId(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, kvm != nullptr, "KVManager is null, failed!"); AppId appId { ctxt->appId }; Status status = kvm->kvDataManager_.GetAllKvStoreId(appId, ctxt->storeIdList); - ZLOGD("execute status=%{public}d", status); + ZLOGD("execute status:%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; }; auto output = [env, ctxt](napi_value& result) { ctxt->status = JSUtil::SetValue(env, ctxt->storeIdList, result); - ZLOGD("output status=%{public}d", ctxt->status); + ZLOGD("output status:%{public}d", ctxt->status); }; return NapiQueue::AsyncWork(env, ctxt, std::string(__FUNCTION__), execute, output); } napi_value JsKVManager::On(napi_env env, napi_callback_info info) { - ZLOGD("KVManager::On()"); auto ctxt = std::make_shared(); auto input = [env, ctxt](size_t argc, napi_value* argv) { // required 2 arguments :: CHECK_ARGS_RETURN_VOID(ctxt, argc == 2, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("subscribe to event=%{public}s", event.c_str()); + ZLOGI("subscribe to event:%{public}s", event.c_str()); CHECK_ARGS_RETURN_VOID(ctxt, event == "distributedDataServiceDie", "invalid arg[0], i.e. invalid event!"); napi_valuetype valueType = napi_undefined; @@ -299,7 +298,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); // required 1 arguments :: - ZLOGI("unsubscribe to event=%{public}s %{public}s specified", event.c_str(), (argc == 1) ? "without": "with"); + ZLOGI("unsubscribe to event:%{public}s %{public}s specified", event.c_str(), (argc == 1) ? "without": "with"); CHECK_ARGS_RETURN_VOID(ctxt, event == "distributedDataServiceDie", "invalid arg[0], i.e. invalid event!"); // have 2 arguments :: have the [callback] if (argc == 2) { @@ -321,7 +320,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) ++it; } } - ZLOGD("off mapsize=%{public}d", static_cast(proxy->deathRecipient_.size())); + ZLOGD("off mapsize: %{public}d", static_cast(proxy->deathRecipient_.size())); }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -331,7 +330,6 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) napi_value JsKVManager::Constructor(napi_env env) { - ZLOGD("KVManager::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("getKVStore", JsKVManager::GetKVStore), DECLARE_NAPI_FUNCTION("closeKVStore", JsKVManager::CloseKVStore), @@ -346,7 +344,6 @@ napi_value JsKVManager::Constructor(napi_env env) napi_value JsKVManager::New(napi_env env, napi_callback_info info) { - ZLOGD("KVManager::New"); std::string bundleName; auto ctxt = std::make_shared(); auto input = [env, ctxt, &bundleName](size_t argc, napi_value* argv) { @@ -359,7 +356,7 @@ napi_value JsKVManager::New(napi_env env, napi_callback_info info) ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - JsKVManager* kvManager = new (std::nothrow) JsKVManager(bundleName); + JsKVManager* kvManager = new (std::nothrow) JsKVManager(bundleName, env); NAPI_ASSERT(env, kvManager !=nullptr, "no memory for kvManager"); auto finalize = [](napi_env env, void* data, void* hint) { diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp index 7af0213f8..b82ae3aa7 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp @@ -182,7 +182,7 @@ napi_value JsKVStore::OnEvent(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, argc >= 2, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("subscribe to event=%{public}s", event.c_str()); + ZLOGI("subscribe to event:%{public}s", event.c_str()); auto handle = onEventHandlers_.find(event); CHECK_ARGS_RETURN_VOID(ctxt, handle != onEventHandlers_.end(), "invalid arg[0], i.e. unsupported event"); // shift 1 argument, for JsKVStore::Exec. @@ -208,7 +208,7 @@ napi_value JsKVStore::OffEvent(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, argc >= 1, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("unsubscribe to event=%{public}s", event.c_str()); + ZLOGI("unsubscribe to event:%{public}s", event.c_str()); auto handle = offEventHandlers_.find(event); CHECK_ARGS_RETURN_VOID(ctxt, handle != offEventHandlers_.end(), "invalid arg[0], i.e. unsupported event"); // shift 1 argument, for JsKVStore::Exec. @@ -228,7 +228,6 @@ napi_value JsKVStore::OffEvent(napi_env env, napi_callback_info info) */ napi_value JsKVStore::PutBatch(napi_env env, napi_callback_info info) { - ZLOGD("in"); struct PutBatchContext : public ContextBase { std::vector entries; }; @@ -260,7 +259,6 @@ napi_value JsKVStore::PutBatch(napi_env env, napi_callback_info info) */ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) { - ZLOGD("in"); struct DeleteBatchContext : public ContextBase { std::vector keys; }; @@ -281,7 +279,7 @@ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) } auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->DeleteBatch(keys); - ZLOGD("kvStore->DeleteBatch return status=%{public}d", status); + ZLOGD("kvStore->DeleteBatch return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->DeleteBatch failed!"); }; @@ -297,14 +295,13 @@ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) */ napi_value JsKVStore::StartTransaction(napi_env env, napi_callback_info info) { - ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->StartTransaction(); - ZLOGD("kvStore->StartTransaction return status=%{public}d", status); + ZLOGD("kvStore->StartTransaction return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->StartTransaction() failed!"); }; @@ -320,14 +317,13 @@ napi_value JsKVStore::StartTransaction(napi_env env, napi_callback_info info) */ napi_value JsKVStore::Commit(napi_env env, napi_callback_info info) { - ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->Commit(); - ZLOGD("kvStore->Commit return status=%{public}d", status); + ZLOGD("kvStore->Commit return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Commit() failed!"); }; @@ -343,14 +339,13 @@ napi_value JsKVStore::Commit(napi_env env, napi_callback_info info) */ napi_value JsKVStore::Rollback(napi_env env, napi_callback_info info) { - ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->Rollback(); - ZLOGD("kvStore->Commit return status=%{public}d", status); + ZLOGD("kvStore->Commit return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Rollback() failed!"); }; @@ -366,7 +361,6 @@ napi_value JsKVStore::Rollback(napi_env env, napi_callback_info info) */ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) { - ZLOGD("in"); struct EnableSyncContext : public ContextBase { bool enable = false; }; @@ -382,7 +376,7 @@ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->SetCapabilityEnabled(ctxt->enable); - ZLOGD("kvStore->SetCapabilityEnabled return status=%{public}d", status); + ZLOGD("kvStore->SetCapabilityEnabled return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->SetCapabilityEnabled() failed!"); }; @@ -398,7 +392,6 @@ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) */ napi_value JsKVStore::SetSyncRange(napi_env env, napi_callback_info info) { - ZLOGD("in"); struct SyncRangeContext : public ContextBase { std::vector localLabels; std::vector remoteSupportLabels; @@ -417,7 +410,7 @@ napi_value JsKVStore::SetSyncRange(napi_env env, napi_callback_info info) auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->SetCapabilityRange(ctxt->localLabels, ctxt->remoteSupportLabels); - ZLOGD("kvStore->SetCapabilityRange return status=%{public}d", status); + ZLOGD("kvStore->SetCapabilityRange return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->SetCapabilityRange() failed!"); }; @@ -444,7 +437,7 @@ void JsKVStore::OnDataChange(napi_env env, size_t argc, napi_value* argv, std::s CHECK_STATUS_RETURN_VOID(ctxt, "napi_typeof failed!"); CHECK_ARGS_RETURN_VOID(ctxt, valueType == napi_function, "invalid arg[2], i.e. invalid callback"); - ZLOGI("subscribe data change type=%{public}d", type); + ZLOGI("subscribe data change type %{public}d", type); auto proxy = reinterpret_cast(ctxt->native); std::lock_guard lck(proxy->listMutex_); for (auto& it : proxy->dataObserver_[type]) { @@ -565,7 +558,6 @@ void JsKVStore::OffSyncComplete(napi_env env, size_t argc, napi_value* argv, std */ napi_status JsKVStore::RegisterSyncCallback(std::shared_ptr callback) { - ZLOGD("in"); Status status = kvStore_->RegisterSyncCallback(callback); if (status != Status::SUCCESS) { callback->Clear(); @@ -580,7 +572,6 @@ napi_status JsKVStore::UnRegisterSyncCallback() { Status status = kvStore_->UnRegisterSyncCallback(); if (status != Status::SUCCESS) { - ZLOGE("unregister SyncCallback error status:%d", status); return napi_generic_failure; } std::lock_guard lck(listMutex_); @@ -595,7 +586,7 @@ napi_status JsKVStore::Subscribe(uint8_t type, std::shared_ptr obs { auto subscribeType = ToSubscribeType(type); Status status = kvStore_->SubscribeKvStore(subscribeType, observer); - ZLOGD("kvStore_->SubscribeKvStore type=%{public}d, return status=%{public}d", type, status); + ZLOGD("kvStore_->SubscribeKvStore(%{public}d) return %{public}d", type, status); if (status != Status::SUCCESS) { observer->Clear(); return napi_generic_failure; @@ -608,7 +599,7 @@ napi_status JsKVStore::UnSubscribe(uint8_t type, std::shared_ptr o { auto subscribeType = ToSubscribeType(type); Status status = kvStore_->UnSubscribeKvStore(subscribeType, observer); - ZLOGD("kvStore_->UnSubscribeKvStore type=%{public}d, return status=%{public}d", type, status); + ZLOGD("kvStore_->UnSubscribeKvStore(%{public}d) return %{public}d", type, status); if (status == Status::SUCCESS) { observer->Clear(); return napi_ok; @@ -624,14 +615,14 @@ void JsKVStore::SetUvQueue(std::shared_ptr uvQueue) void JsKVStore::DataObserver::OnChange(const ChangeNotification ¬ification, std::shared_ptr snapshot) { - ZLOGD("data change insert=%{public}zu, update=%{public}zu, delete=%{public}zu", + ZLOGD("data change insert:%{public}zu, update:%{public}zu, delete:%{public}zu", notification.GetInsertEntries().size(), notification.GetUpdateEntries().size(), notification.GetDeleteEntries().size()); } -void DataObserver::OnChange(const ChangeNotification& notification) +void JsKVStore::DataObserver::OnChange(const ChangeNotification& notification) { - ZLOGD("data change insert=%{public}zu, update=%{public}zu, delete=%{public}zu", + ZLOGD("data change insert:%{public}zu, update:%{public}zu, delete:%{public}zu", notification.GetInsertEntries().size(), notification.GetUpdateEntries().size(), notification.GetDeleteEntries().size()); KvStoreObserver::OnChange(notification); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp index 3ca019cab..4605d44c7 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp @@ -33,7 +33,6 @@ std::shared_ptr& JsKVStoreResultSet::GetNative() napi_value JsKVStoreResultSet::Constructor(napi_env env) { - ZLOGD("KVManager::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("getCount", JsKVStoreResultSet::GetCount), DECLARE_NAPI_FUNCTION("getPosition", JsKVStoreResultSet::GetPosition), @@ -189,7 +188,7 @@ napi_value JsKVStoreResultSet::MoveToPosition(napi_env env, napi_callback_info i }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - ZLOGD("KVStoreResultSet::MoveToPosition position=%{public}d", position); + ZLOGD("KVStoreResultSet::MoveToPosition(%{public}d)", position); auto& resultSet = reinterpret_cast(ctxt->native)->resultSet_; bool isMoved = resultSet->MoveToPosition(position); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_observer.cpp b/frameworks/jskitsimpl/distributeddata/src/js_observer.cpp new file mode 100644 index 000000000..394abf37d --- /dev/null +++ b/frameworks/jskitsimpl/distributeddata/src/js_observer.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "js_observer.h" + +namespace OHOS::DistributedData { +void JSObserver::Clear() +{ + // Clear() run in js main thread, so it serial run with AsyncCall() lambda, so we can use no lock. + if (callback_ == nullptr) { + return ; + } + napi_delete_reference(uvQueue_->GetEnv(), callback_); + callback_ = nullptr; +} + +JSObserver::JSObserver(std::shared_ptr uvQueue, napi_value callback) + : uvQueue_(uvQueue) +{ + napi_create_reference(uvQueue_->GetEnv(), callback, 1, &callback_); +} + +JSObserver::~JSObserver() +{ +} + +napi_ref JSObserver::GetCallback() +{ + return callback_; +} + +void JSObserver::AsyncCall(UvQueue::NapiArgsGenerator genArgs) +{ + if (callback_ == nullptr) { + return; + } + + uvQueue_->AsyncCall([observer = shared_from_this()](napi_env env) -> napi_value { + // the lambda run in js main thread, so it serial run with Clear(), so we can use no lock. + if (observer->callback_ == nullptr) { + return nullptr; + } + napi_value callback = nullptr; + napi_get_reference_value(env, observer->callback_, &callback); + return callback; + }, genArgs); +} +} \ No newline at end of file diff --git a/frameworks/jskitsimpl/distributeddata/src/js_query.cpp b/frameworks/jskitsimpl/distributeddata/src/js_query.cpp index d691f4ceb..7f59047ed 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_query.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_query.cpp @@ -67,7 +67,6 @@ napi_value JsQuery::Constructor(napi_env env) */ napi_value JsQuery::New(napi_env env, napi_callback_info info) { - ZLOGD("Query::New()"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -347,7 +346,6 @@ struct NumbersContext : public ContextBase { napi_value JsQuery::InNumber(napi_env env, napi_callback_info info) { - ZLOGD("Query::InNumber()"); auto ctxt = std::make_shared(); ctxt->GetNumberSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -365,7 +363,6 @@ napi_value JsQuery::InNumber(napi_env env, napi_callback_info info) napi_value JsQuery::InString(napi_env env, napi_callback_info info) { - ZLOGD("Query::InString()"); struct StringsContext : public ContextBase { std::string field; std::vector valueList; @@ -389,7 +386,6 @@ napi_value JsQuery::InString(napi_env env, napi_callback_info info) napi_value JsQuery::NotInNumber(napi_env env, napi_callback_info info) { - ZLOGD("Query::NotInNumber()"); auto ctxt = std::make_shared(); ctxt->GetNumberSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -541,7 +537,6 @@ napi_value JsQuery::OrderByDesc(napi_env env, napi_callback_info info) napi_value JsQuery::Limit(napi_env env, napi_callback_info info) { - ZLOGD("Query::Limit()"); struct LimitContext : public ContextBase { int number; int offset; @@ -606,7 +601,6 @@ napi_value JsQuery::EndGroup(napi_env env, napi_callback_info info) napi_value JsQuery::PrefixKey(napi_env env, napi_callback_info info) { - ZLOGD("Query::PrefixKey()"); std::string prefix; auto ctxt = std::make_shared(); auto input = [env, ctxt, &prefix](size_t argc, napi_value* argv) { @@ -625,7 +619,6 @@ napi_value JsQuery::PrefixKey(napi_env env, napi_callback_info info) napi_value JsQuery::SetSuggestIndex(napi_env env, napi_callback_info info) { - ZLOGD("Query::SetSuggestIndex()"); std::string suggestIndex; auto ctxt = std::make_shared(); auto input = [env, ctxt, &suggestIndex](size_t argc, napi_value* argv) { @@ -644,7 +637,6 @@ napi_value JsQuery::SetSuggestIndex(napi_env env, napi_callback_info info) napi_value JsQuery::DeviceId(napi_env env, napi_callback_info info) { - ZLOGD("Query::DeviceId()"); std::string deviceId; auto ctxt = std::make_shared(); auto input = [env, ctxt, &deviceId](size_t argc, napi_value* argv) { @@ -664,7 +656,6 @@ napi_value JsQuery::DeviceId(napi_env env, napi_callback_info info) // getSqlLike():string napi_value JsQuery::GetSqlLike(napi_env env, napi_callback_info info) { - ZLOGD("Query::GetSqlLike()"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp b/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp index 63e61c346..5a457bb06 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp @@ -87,7 +87,6 @@ napi_status JsSchema::ToJson(napi_env env, napi_value inner, JsSchema*& out) JsSchema* JsSchema::GetSchema(napi_env env, napi_callback_info info, std::shared_ptr& ctxt) { - ZLOGD("Schema::GetSchema"); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); return reinterpret_cast(ctxt->native); @@ -96,7 +95,6 @@ JsSchema* JsSchema::GetSchema(napi_env env, napi_callback_info info, std::shared template napi_value JsSchema::GetContextValue(napi_env env, std::shared_ptr& ctxt, T& value) { - ZLOGD("Schema::GetContextValue"); JSUtil::SetValue(env, value, ctxt->output); return ctxt->output; } @@ -154,7 +152,6 @@ napi_value JsSchema::GetMode(napi_env env, napi_callback_info info) napi_value JsSchema::SetMode(napi_env env, napi_callback_info info) { - ZLOGD("Schema::SetMode"); auto ctxt = std::make_shared(); uint32_t mode = false; auto input = [env, ctxt, &mode](size_t argc, napi_value* argv) { @@ -181,7 +178,6 @@ napi_value JsSchema::GetSkip(napi_env env, napi_callback_info info) napi_value JsSchema::SetSkip(napi_env env, napi_callback_info info) { - ZLOGD("Schema::SetSkip"); auto ctxt = std::make_shared(); uint32_t skip = false; auto input = [env, ctxt, &skip](size_t argc, napi_value* argv) { @@ -208,7 +204,6 @@ napi_value JsSchema::GetIndexes(napi_env env, napi_callback_info info) napi_value JsSchema::SetIndexes(napi_env env, napi_callback_info info) { - ZLOGD("Schema::SetIndexes"); auto ctxt = std::make_shared(); std::vector indexes; auto input = [env, ctxt, &indexes](size_t argc, napi_value* argv) { diff --git a/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp index b7d13e0cb..1444f488b 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp @@ -31,7 +31,6 @@ JsSingleKVStore::JsSingleKVStore(const std::string& storeId) napi_value JsSingleKVStore::Constructor(napi_env env) { - ZLOGD("JsSingleKVStore::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("put", JsKVStore::Put), DECLARE_NAPI_FUNCTION("delete", JsKVStore::Delete), @@ -163,11 +162,11 @@ napi_value JsSingleKVStore::GetEntries(napi_env env, napi_callback_info info) if (ctxt->va.type == ArgsType::KEYPREFIX) { OHOS::DistributedKv::Key keyPrefix(ctxt->va.keyPrefix); status = kvStore->GetEntries(keyPrefix, ctxt->entries); - ZLOGD("kvStore->GetEntries() return status=%{public}d", status); + ZLOGD("kvStore->GetEntries() return %{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetEntries() failed"); @@ -215,11 +214,11 @@ napi_value JsSingleKVStore::GetResultSet(napi_env env, napi_callback_info info) if (ctxt->va.type == ArgsType::KEYPREFIX) { OHOS::DistributedKv::Key keyPrefix(ctxt->va.keyPrefix); status = kvStore->GetResultSet(keyPrefix, kvResultSet); - ZLOGD("kvStore->GetEntries() return status=%{public}d", status); + ZLOGD("kvStore->GetEntries() return %{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetResultSet() failed!"); @@ -260,7 +259,7 @@ napi_value JsSingleKVStore::CloseResultSet(napi_env env, napi_callback_info info auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->CloseResultSet(ctxt->resultSet->GetNative()); - ZLOGD("kvStore->CloseResultSet return status=%{public}d", status); + ZLOGD("kvStore->CloseResultSet return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->CloseResultSet failed!"); }; @@ -294,7 +293,7 @@ napi_value JsSingleKVStore::GetResultSize(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); auto query = ctxt->query->GetNative(); Status status = kvStore->GetCountWithQuery(query.ToString(), ctxt->resultSize); - ZLOGD("kvStore->GetCountWithQuery() return status=%{public}d", status); + ZLOGD("kvStore->GetCountWithQuery() return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetCountWithQuery() failed!"); }; @@ -328,7 +327,7 @@ napi_value JsSingleKVStore::RemoveDeviceData(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->RemoveDeviceData(ctxt->deviceId); - ZLOGD("kvStore->RemoveDeviceData return status=%{public}d", status); + ZLOGD("kvStore->RemoveDeviceData return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->RemoveDeviceData failed!"); }; @@ -363,12 +362,12 @@ napi_value JsSingleKVStore::Sync(napi_env env, napi_callback_info info) }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - ZLOGD("sync deviceIdList.size=%{public}d, mode=%{public}u, allowedDelayMs=%{public}u", + ZLOGD("sync deviceIdList.size=%{public}d, mode:%{public}u, allowedDelayMs:%{public}u", (int)ctxt->deviceIdList.size(), ctxt->mode, ctxt->allowedDelayMs); auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Sync(ctxt->deviceIdList, static_cast(ctxt->mode), ctxt->allowedDelayMs); - ZLOGD("kvStore->Sync return status=%{public}d!", status); + ZLOGD("kvStore->Sync return %{public}d!", status); NAPI_ASSERT(env, status == Status::SUCCESS, "kvStore->Sync() failed!"); return nullptr; } @@ -397,7 +396,7 @@ napi_value JsSingleKVStore::SetSyncParam(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); KvSyncParam syncParam { ctxt->allowedDelayMs }; Status status = kvStore->SetSyncParam(syncParam); - ZLOGD("kvStore->SetSyncParam return status=%{public}d", status); + ZLOGD("kvStore->SetSyncParam return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "output failed!"); }; @@ -421,7 +420,7 @@ napi_value JsSingleKVStore::GetSecurityLevel(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->GetSecurityLevel(ctxt->securityLevel); - ZLOGD("kvStore->GetSecurityLevel return status=%{public}d", status); + ZLOGD("kvStore->GetSecurityLevel return %{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "GetSecurityLevel failed!"); }; diff --git a/frameworks/jskitsimpl/distributeddata/src/js_util.cpp b/frameworks/jskitsimpl/distributeddata/src/js_util.cpp index f8e60df5f..30addf604 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_util.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_util.cpp @@ -94,7 +94,7 @@ napi_status JSUtil::GetValue(napi_env env, napi_value in, std::string& out) if (maxLen <= 0) { return status; } - ZLOGD("napi_value -> std::string get length=%{public}d", (int)maxLen); + ZLOGD("napi_value -> std::string get length %{public}d", (int)maxLen); char* buf = new (std::nothrow) char[maxLen + STR_TAIL_LENGTH]; if (buf != nullptr) { size_t len = 0; @@ -164,7 +164,7 @@ JSUtil::KvStoreVariant JSUtil::Blob2VariantValue(const DistributedKv::Blob& blob } // number 1 means: skip the first byte, byte[0] is real data type. std::vector real(data.begin() + 1, data.end()); - ZLOGD("Blob::type=%{public}d size=%{public}d", static_cast(data[0]), static_cast(real.size())); + ZLOGD("Blob::type %{public}d size=%{public}d", static_cast(data[0]), static_cast(real.size())); if (data[0] == JSUtil::INTEGER) { uint32_t tmp4int = be32toh(*reinterpret_cast(&(real[0]))); return JSUtil::KvStoreVariant(*reinterpret_cast(&tmp4int)); @@ -971,7 +971,6 @@ napi_ref JSUtil::NewWithRef(napi_env env, size_t argc, napi_value* argv, void** napi_status JSUtil::Unwrap(napi_env env, napi_value in, void** out, napi_value constructor) { - ZLOGD("JSUtil::Unwrap"); if (constructor != nullptr) { bool isInstance = false; napi_instanceof(env, in, constructor, &isInstance); diff --git a/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp b/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp index da336ed6f..e09d7ac17 100644 --- a/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp @@ -119,12 +119,10 @@ void NapiQueue::GenerateOutput(ContextBase* ctxt) if (ctxt->status == napi_ok) { napi_get_undefined(ctxt->env, &result[RESULT_ERROR]); if (ctxt->output == nullptr) { - ZLOGD("ctxt->output is nullptr"); napi_get_undefined(ctxt->env, &ctxt->output); } result[RESULT_DATA] = ctxt->output; } else { - ZLOGD("ctxt->status != napi_ok"); napi_value message = nullptr; napi_create_string_utf8(ctxt->env, ctxt->error.c_str(), NAPI_AUTO_LENGTH, &message); napi_create_error(ctxt->env, nullptr, message, &result[RESULT_ERROR]); diff --git a/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp b/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp index dcc564b38..8a58d08c0 100644 --- a/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/uv_queue.cpp @@ -70,7 +70,7 @@ void UvQueue::AsyncCall(NapiCallbackGetter getter, NapiArgsGenerator genArgs) napi_value result; napi_status status = napi_call_function(entry->env, global, method, argc, argv, &result); if (status != napi_ok) { - ZLOGE("notify data change failed status=%{public}d callback=%{public}p", status, method); + ZLOGE("notify data change failed status:%{public}d callback:%{public}p", status, method); } }); } diff --git a/services/distributeddataservice/adapter/account/src/account_delegate.cpp b/services/distributeddataservice/adapter/account/src/account_delegate.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp b/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/src/constant.cpp b/services/distributeddataservice/adapter/autils/src/constant.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/src/directory_utils.cpp b/services/distributeddataservice/adapter/autils/src/directory_utils.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/src/kv_scheduler.cpp b/services/distributeddataservice/adapter/autils/src/kv_scheduler.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_task.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_task.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp old mode 100755 new mode 100644 index 6f9874a95..b3af3f038 --- a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp +++ b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread.cpp @@ -21,7 +21,6 @@ namespace OHOS { namespace DistributedKv { KvStoreThread::KvStoreThread(KvStoreThreadPool *threadPool) - : pool_(threadPool) { realThread_ = std::thread([&, threadPool]() { // this makes me unconfortable: this lambda capture 'this' by reference, and right after this call this object @@ -31,11 +30,6 @@ KvStoreThread::KvStoreThread(KvStoreThreadPool *threadPool) }); } -KvStoreThread::KvStoreThread(KvStoreThread &&thread) : pool_(thread.pool_) -{ - realThread_ = std::move(thread.realThread_); -} - void KvStoreThread::Run(KvStoreThreadPool *pool) { if (pool == nullptr) { diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool_impl.cpp b/services/distributeddataservice/adapter/autils/src/thread_pool/kv_store_thread_pool_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/autils/test/unittest/kv_scheduler_test.cpp b/services/distributeddataservice/adapter/autils/test/unittest/kv_scheduler_test.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender.cpp b/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender_impl.cpp b/services/distributeddataservice/adapter/broadcaster/src/broadcast_sender_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/app_device_handler.cpp b/services/distributeddataservice/adapter/communicator/src/app_device_handler.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp b/services/distributeddataservice/adapter/communicator/src/app_pipe_handler.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp b/services/distributeddataservice/adapter/communicator/src/app_pipe_mgr.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/ark_communication_provider.cpp b/services/distributeddataservice/adapter/communicator/src/ark_communication_provider.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/communication_provider_impl.cpp b/services/distributeddataservice/adapter/communicator/src/communication_provider_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp b/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp old mode 100755 new mode 100644 index c52686eb6..d15638598 --- a/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp +++ b/services/distributeddataservice/adapter/communicator/src/data_buffer.cpp @@ -19,6 +19,14 @@ namespace OHOS { namespace AppDistributedKv { int DataBuffer::sequence_ = 0; +const size_t DataBuffer::MAX_DATA_LEN = 1024 * 1024 * 5; + +const int DataBuffer::MAX_TRANSFER_SIZE = 1024 * 1024 * 5 - DataBuffer::HEADER_LEN; + +const uint32_t DataBuffer::VERSION = 0; + +const uint32_t DataBuffer::TYPE = 0; + DataBuffer::DataBuffer() : buf_(nullptr), size_(0), used_(0) {} diff --git a/services/distributeddataservice/adapter/communicator/src/process_communicator_impl.cpp b/services/distributeddataservice/adapter/communicator/src/process_communicator_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp old mode 100755 new mode 100644 index 44504483f..70e2bfa3f --- a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp +++ b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp @@ -689,7 +689,7 @@ void AppDataListenerWrap::OnSessionClosed(int sessionId) } ret = GetPeerSessionName(sessionId, peerSessionName, sizeof(peerSessionName)); if (ret != SOFTBUS_OK) { - ZLOGW("get my peer session name failed, session id is %{public}d.", sessionId); + ZLOGW("get my peer session name failed."); return; } ret = GetPeerDeviceId(sessionId, peerDevId, sizeof(peerDevId)); diff --git a/services/distributeddataservice/adapter/dfx/src/dds_trace.cpp b/services/distributeddataservice/adapter/dfx/src/dds_trace.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/communication_fault_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/database_fault_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/fault/fault_reporter.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/runtime_fault_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp b/services/distributeddataservice/adapter/dfx/src/fault/service_fault_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/reporter.cpp b/services/distributeddataservice/adapter/dfx/src/reporter.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/api_performance_statistic_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/database_statistic_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/statistic_reporter.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/traffic_statistic_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp b/services/distributeddataservice/adapter/dfx/src/statistic/visit_statistic_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/permission/src/client_permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/client_permission_validator.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/permission/test/unittest/permission_validator_test.cpp b/services/distributeddataservice/adapter/permission/test/unittest/permission_validator_test.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/adapter/utils/src/kvstore_utils.cpp b/services/distributeddataservice/adapter/utils/src/kvstore_utils.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/backup_handler.cpp b/services/distributeddataservice/app/src/backup_handler.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp b/services/distributeddataservice/app/src/flowctrl_manager/kvstore_flowctrl_manager.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_account_observer.cpp b/services/distributeddataservice/app/src/kvstore_account_observer.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_app_accessor.cpp b/services/distributeddataservice/app/src/kvstore_app_accessor.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_app_manager.cpp b/services/distributeddataservice/app/src/kvstore_app_manager.cpp old mode 100755 new mode 100644 index d46d36494..1183f916e --- a/services/distributeddataservice/app/src/kvstore_app_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_app_manager.cpp @@ -436,7 +436,7 @@ KvStoreAppManager::PathType KvStoreAppManager::ConvertPathType(int32_t uid, cons default: break; } - auto *checker = CheckerManager::GetInstance().GetChecker("SystemChecker"); + auto *checker = CheckerManager::GetInstance().GetChecker(CheckerManager::SYSTEM_CHECKER); if (checker == nullptr || !checker->IsValid(uid, bundleName)) { return PATH_CE; } diff --git a/services/distributeddataservice/app/src/kvstore_impl.cpp b/services/distributeddataservice/app/src/kvstore_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_resultset_impl.cpp b/services/distributeddataservice/app/src/kvstore_resultset_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_snapshot_impl.cpp b/services/distributeddataservice/app/src/kvstore_snapshot_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_sync_manager.cpp b/services/distributeddataservice/app/src/kvstore_sync_manager.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/kvstore_user_manager.cpp b/services/distributeddataservice/app/src/kvstore_user_manager.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/security/security.cpp b/services/distributeddataservice/app/src/security/security.cpp index 3874ac43b..1f1e96529 100644 --- a/services/distributeddataservice/app/src/security/security.cpp +++ b/services/distributeddataservice/app/src/security/security.cpp @@ -164,7 +164,6 @@ Sensitive Security::GetSensitiveByUuid(const std::string &uuid) sensitive = value; return true; } - auto &network = AppDistributedKv::CommunicationProvider::GetInstance(); auto devices = network.GetRemoteNodesBasicInfo(); devices.push_back(network.GetLocalBasicInfo()); diff --git a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp index 2158affa1..513e8e550 100644 --- a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp +++ b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp @@ -212,6 +212,10 @@ bool RouteHeadHandlerImpl::UnPackData(const uint8_t *data, uint32_t totalLen, ui bool RouteHeadHandlerImpl::UnPackDataHead(const uint8_t *data, uint32_t totalLen, RouteHead &routeHead) { + if (totalLen < sizeof(RouteHead)) { + ZLOGE("invalid route head len"); + return false; + } const RouteHead *head = reinterpret_cast(data); routeHead.magic = NetToHost(head->magic); routeHead.version = NetToHost(head->version); @@ -221,8 +225,8 @@ bool RouteHeadHandlerImpl::UnPackDataHead(const uint8_t *data, uint32_t totalLen ZLOGW("not route head data"); return false; } - if (routeHead.dataLen + sizeof(RouteHead) > totalLen) { - ZLOGE("invalid route head len"); + if (totalLen - sizeof(RouteHead) < routeHead.dataLen) { + ZLOGE("invalid route data len"); return false; } return true; @@ -250,14 +254,16 @@ bool RouteHeadHandlerImpl::UnPackDataBody(const uint8_t *data, uint32_t totalLen const SessionUserPair *userPair = reinterpret_cast(ptr); session_.sourceUserId = NetToHost(userPair->sourceUserId); - if (leftSize < sizeof(SessionUserPair) + userPair->targetUserCount * sizeof(int)) { + auto userPairSize = sizeof(SessionUserPair) + userPair->targetUserCount * sizeof(uint32_t); + if (leftSize < userPairSize) { ZLOGE("failed to parse user pair, target user"); return false; } for (int i = 0; i < userPair->targetUserCount; ++i) { session_.targetUserIds.push_back(NetToHost(*(userPair->targetUserIds + i))); } - ptr += sizeof(SessionUserPair) + userPair->targetUserCount * sizeof(int); + ptr += userPairSize; + leftSize -= userPairSize; if (leftSize < sizeof(SessionAppId)) { ZLOGE("failed to parse app id len"); @@ -265,7 +271,7 @@ bool RouteHeadHandlerImpl::UnPackDataBody(const uint8_t *data, uint32_t totalLen } const SessionAppId *appId = reinterpret_cast(ptr); auto appIdLen = NetToHost(appId->len); - if (leftSize < sizeof(SessionAppId) + appIdLen) { + if (leftSize - sizeof(SessionAppId) < appIdLen) { ZLOGE("failed to parse app id"); return false; } diff --git a/services/distributeddataservice/app/src/session_manager/session_manager.cpp b/services/distributeddataservice/app/src/session_manager/session_manager.cpp index 1f54406b0..16b4bba46 100644 --- a/services/distributeddataservice/app/src/session_manager/session_manager.cpp +++ b/services/distributeddataservice/app/src/session_manager/session_manager.cpp @@ -17,6 +17,8 @@ #define LOG_TAG "SessionManager" +#include + #include "auth/auth_delegate.h" #include "checker/checker_manager.h" #include "log/log_print.h" @@ -39,11 +41,23 @@ Session SessionManager::GetSession(const SessionPoint &from, const std::string & session.sourceUserId = from.userId; session.sourceDeviceId = from.deviceId; session.targetDeviceId = targetDeviceId; + + // system service + if (from.userId == UserDelegate::SYSTEM_USER) { + auto *checker = CheckerManager::GetInstance().GetChecker(CheckerManager::SYSTEM_CHECKER); + if (checker != nullptr && checker->IsValid(UserDelegate::SYSTEM_USER, from.appId)) { + session.targetUserIds.push_back(UserDelegate::SYSTEM_USER); + } + } + for (const auto &user : users) { bool isPermitted = AuthDelegate::GetInstance()->CheckAccess(from.userId, user.id, targetDeviceId, from.appId); ZLOGD("access to peer user %{public}d is %{public}d", user.id, isPermitted); if (isPermitted) { - session.targetUserIds.push_back(user.id); + auto it = std::find(session.targetUserIds.begin(), session.targetUserIds.end(), user.id); + if (it == session.targetUserIds.end()) { + session.targetUserIds.push_back(user.id); + } } } ZLOGD("end"); diff --git a/services/distributeddataservice/app/src/single_kvstore_impl.cpp b/services/distributeddataservice/app/src/single_kvstore_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/uninstaller/uninstaller.cpp b/services/distributeddataservice/app/src/uninstaller/uninstaller.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/app/src/uninstaller/uninstaller_impl.cpp b/services/distributeddataservice/app/src/uninstaller/uninstaller_impl.cpp old mode 100755 new mode 100644 diff --git a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp index 979b3dd4f..3ad52cb03 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/auto_launch.cpp @@ -143,7 +143,7 @@ int AutoLaunch::EnableKvStoreAutoLaunchParmCheck(AutoLaunchItem &autoLaunchItem, return -E_ALREADY_SET; } uint32_t autoLaunchItemSize = 0; - for (const auto item : autoLaunchItemMap_) { + for (const auto &item : autoLaunchItemMap_) { autoLaunchItemSize += item.second.size(); } if (autoLaunchItemSize == MAX_AUTO_LAUNCH_ITEM_NUM) { @@ -206,7 +206,6 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st return E_OK; } if (autoLaunchItem.conn == nullptr) { - LOGE("[AutoLaunch] GetKVConnectionInEnable GetDatabaseConnection errCode:%d", errCode); std::lock_guard autoLock(dataLock_); EraseAutoLauchItem(identifier, userId); return errCode; @@ -236,7 +235,6 @@ int AutoLaunch::GetKVConnectionInEnable(AutoLaunchItem &autoLaunchItem, const st autoLaunchItemMap_[identifier][userId].state = AutoLaunchItemState::IDLE; autoLaunchItemMap_[identifier][userId].conn = autoLaunchItem.conn; autoLaunchItemMap_[identifier][userId].observerHandle = autoLaunchItem.observerHandle; - LOGI("[AutoLaunch] GetKVConnectionInEnable RegisterObserverAndLifeCycleCallback ok"); } else { LOGE("[AutoLaunch] GetKVConnectionInEnable RegisterObserverAndLifeCycleCallback err, do CloseConnection"); TryCloseConnection(autoLaunchItem); // do nothing if failed @@ -829,21 +827,27 @@ void AutoLaunch::AutoLaunchExtTask(const std::string identifier, const std::stri } extItemMap_[identifier][userId] = autoLaunchItem; } - int errCode = OpenOneConnection(autoLaunchItem); - LOGI("[AutoLaunch] AutoLaunchExtTask GetOneConnection errCode:%d", errCode); - if (autoLaunchItem.conn == nullptr) { - std::lock_guard autoLock(extLock_); - extItemMap_[identifier].erase(userId); - if (extItemMap_[identifier].size() == 0) { - extItemMap_.erase(identifier); + bool abort = false; + do { + int errCode = CheckAutoLaunchRealPath(autoLaunchItem); + if (errCode != E_OK) { + abort = true; + break; } - return; - } - - errCode = RegisterObserverAndLifeCycleCallback(autoLaunchItem, identifier, true); - if (errCode != E_OK) { - LOGE("[AutoLaunch] AutoLaunchExtTask RegisterObserverAndLifeCycleCallback failed"); - TryCloseConnection(autoLaunchItem); // if here failed, do nothing + errCode = OpenOneConnection(autoLaunchItem); + LOGI("[AutoLaunch] AutoLaunchExtTask GetOneConnection errCode:%d", errCode); + if (autoLaunchItem.conn == nullptr) { + abort = true; + break; + } + errCode = RegisterObserverAndLifeCycleCallback(autoLaunchItem, identifier, true); + if (errCode != E_OK) { + LOGE("[AutoLaunch] AutoLaunchExtTask RegisterObserverAndLifeCycleCallback failed"); + TryCloseConnection(autoLaunchItem); // if here failed, do nothing + abort = true; + } + } while (false); + if (abort) { std::lock_guard autoLock(extLock_); extItemMap_[identifier].erase(userId); if (extItemMap_[identifier].size() == 0) { @@ -1081,14 +1085,6 @@ int AutoLaunch::OpenKvConnection(AutoLaunchItem &autoLaunchItem) std::shared_ptr properties = std::static_pointer_cast(autoLaunchItem.propertiesPtr); int errCode = E_OK; - std::string canonicalDir; - std::string dataDir; - properties->GetStringProp(KvDBProperties::DATA_DIR, dataDir); - if (!ParamCheckUtils::CheckDataDir(dataDir, canonicalDir)) { - LOGE("[AutoLaunch] CheckDataDir is invalid Auto Launch failed."); - return -E_INVALID_ARGS; - } - properties->SetStringProp(KvDBProperties::DATA_DIR, canonicalDir); IKvDBConnection *conn = KvDBManager::GetDatabaseConnection(*properties, errCode, false); if (errCode == -E_ALREADY_OPENED) { LOGI("[AutoLaunch] GetOneConnection user already getkvstore by self"); @@ -1210,4 +1206,33 @@ void AutoLaunch::EraseAutoLauchItem(const std::string &identifier, const std::st autoLaunchItemMap_.erase(identifier); } } + +void AutoLaunch::NotifyInvalidParam(const AutoLaunchItem &autoLaunchItem) +{ + if (!autoLaunchItem.notifier) { + return; + } + int retCode = RuntimeContext::GetInstance()->ScheduleTask([autoLaunchItem] { + std::string userId = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::USER_ID, ""); + std::string appId = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::APP_ID, ""); + std::string storeId = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::STORE_ID, ""); + autoLaunchItem.notifier(userId, appId, storeId, INVALID_PARAM); + }); + if (retCode != E_OK) { + LOGE("[AutoLaunch] AutoLaunchExt notifier ScheduleTask retCode:%d", retCode); + } +} + +int AutoLaunch::CheckAutoLaunchRealPath(const AutoLaunchItem &autoLaunchItem) +{ + std::string canonicalDir; + std::string dataDir = autoLaunchItem.propertiesPtr->GetStringProp(DBProperties::DATA_DIR, ""); + if (!ParamCheckUtils::CheckDataDir(dataDir, canonicalDir)) { + LOGE("[AutoLaunch] CheckDataDir is invalid Auto Launch failed."); + NotifyInvalidParam(autoLaunchItem); + return -E_INVALID_ARGS; + } + autoLaunchItem.propertiesPtr->SetStringProp(DBProperties::DATA_DIR, canonicalDir); + return E_OK; +} } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp b/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp index 1d498a370..54c3b82f2 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/param_check_utils.cpp @@ -28,7 +28,6 @@ bool ParamCheckUtils::CheckDataDir(const std::string &dataDir, std::string &cano } if (OS::GetRealPath(dataDir, canonicalDir) != E_OK) { - LOGE("Failed to canonicalize the data dir."); return false; } // After normalizing the path, determine whether the path is a legal path considered by the program. diff --git a/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp b/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp index 01f32ea65..e3b2f58e5 100644 --- a/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp +++ b/services/distributeddataservice/libs/distributeddb/common/src/platform_specific.cpp @@ -144,7 +144,7 @@ int GetRealPath(const std::string &inOriPath, std::string &outRealPath) } if (realpath(inOriPath.c_str(), realPath) == nullptr) { - LOGE("[RealPath] Get realpath for inOriPath fail:%d.", errno); + LOGE("[OS] Realpath error:%d.", errno); delete []realPath; return -E_SYSTEM_API_FAIL; } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp index 0937ecb35..0a2161a96 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator.cpp @@ -47,7 +47,7 @@ int Communicator::RegOnConnectCallback(const OnConnectCallback &onConnect, const if (onConnect && errCode == E_OK) { // Register action and success for (auto &entry : onlineTargets_) { - LOGI("[Comm][RegConnect] Label=%s, online target=%s{private}.", VEC_TO_STR(commLabel_), entry.c_str()); + LOGI("[Comm][RegConnect] Label=%.6s, online target=%s{private}.", VEC_TO_STR(commLabel_), entry.c_str()); onConnectHandle_(entry, true); } } diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp index 5614b31a9..1ec0fa24a 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/communicator_aggregator.cpp @@ -136,7 +136,7 @@ ICommunicator *CommunicatorAggregator::AllocCommunicator(uint64_t commLabel, int ICommunicator *CommunicatorAggregator::AllocCommunicator(const std::vector &commLabel, int &outErrorNo) { std::lock_guard commMapLockGuard(commMapMutex_); - LOGI("[CommAggr][Alloc] Label=%s.", VEC_TO_STR(commLabel)); + LOGI("[CommAggr][Alloc] Label=%.6s.", VEC_TO_STR(commLabel)); if (commLabel.size() != COMM_LABEL_LENGTH) { outErrorNo = -E_INVALID_ARGS; return nullptr; @@ -163,7 +163,7 @@ void CommunicatorAggregator::ReleaseCommunicator(ICommunicator *inCommunicator) } Communicator *commPtr = static_cast(inCommunicator); LabelType commLabel = commPtr->GetCommunicatorLabel(); - LOGI("[CommAggr][Release] Label=%s.", VEC_TO_STR(commLabel)); + LOGI("[CommAggr][Release] Label=%.6s.", VEC_TO_STR(commLabel)); std::lock_guard commMapLockGuard(commMapMutex_); if (commMap_.count(commLabel) == 0) { @@ -234,7 +234,7 @@ int CommunicatorAggregator::GetLocalIdentity(std::string &outTarget) const void CommunicatorAggregator::ActivateCommunicator(const LabelType &commLabel) { std::lock_guard commMapLockGuard(commMapMutex_); - LOGI("[CommAggr][Activate] Label=%s.", VEC_TO_STR(commLabel)); + LOGI("[CommAggr][Activate] Label=%.6s.", VEC_TO_STR(commLabel)); if (commMap_.count(commLabel) == 0) { LOGW("[CommAggr][Activate] Communicator of this label not allocated."); return; diff --git a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp index f0b4f6302..93c7e14a9 100644 --- a/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp +++ b/services/distributeddataservice/libs/distributeddb/communicator/src/protocol_proto.cpp @@ -399,6 +399,16 @@ int ProtocolProto::SetDivergeHeader(SerialBuffer *inBuff, const LabelType &inCom return E_OK; } +namespace { +void FillPhyHeaderLenInfo(CommPhyHeader &header, uint32_t packetLen, uint64_t sum, uint8_t type, uint8_t paddingLen) +{ + header.packetLen = packetLen; + header.checkSum = sum; + header.packetType |= type; + header.paddingLen = paddingLen; +} +} + int ProtocolProto::SetPhyHeader(SerialBuffer *inBuff, const PhyHeaderInfo &inInfo) { if (inBuff == nullptr) { @@ -423,13 +433,11 @@ int ProtocolProto::SetPhyHeader(SerialBuffer *inBuff, const PhyHeaderInfo &inInf CommPhyHeader phyHeader; phyHeader.magic = MAGIC_CODE; phyHeader.version = PROTOCOL_VERSION; - phyHeader.packetLen = packetLen; - phyHeader.checkSum = 0; // Sum is calculated afterwards phyHeader.sourceId = inInfo.sourceId; phyHeader.frameId = inInfo.frameId; - phyHeader.packetType = packetType; - phyHeader.paddingLen = paddingLen; + phyHeader.packetType = 0; phyHeader.dbIntVer = DB_GLOBAL_VERSION; + FillPhyHeaderLenInfo(phyHeader, packetLen, 0, packetType, paddingLen); // Sum is calculated afterwards HeaderConverter::ConvertHostToNet(phyHeader, phyHeader); errno_t retCode = memcpy_s(headerByteLen.first, headerByteLen.second, &phyHeader, sizeof(CommPhyHeader)); @@ -934,8 +942,8 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram for (auto &entry : outPieces) { // subtract 1 for index uint32_t pieceFragLen = (fragNo != fragmentInfo.fragCount - 1) ? quotient : (quotient + remainder); - uint32_t alignedPieceFragLen = BYTE_8_ALIGN(pieceFragLen); // Add padding length - uint32_t pieceTotalLen = alignedPieceFragLen + sizeof(CommPhyHeader) + sizeof(CommPhyOptHeader); + uint32_t alignedFragLen = BYTE_8_ALIGN(pieceFragLen); // Add padding length + uint32_t pieceTotalLen = alignedFragLen + sizeof(CommPhyHeader) + sizeof(CommPhyOptHeader); // Since exception is disabled, we have to check the vector size to assure that memory is truly allocated entry.first.resize(pieceTotalLen + fragmentInfo.extendHeadSize); // Note: should use resize other than reserve @@ -946,10 +954,10 @@ int ProtocolProto::FrameFragmentation(const uint8_t *splitStartBytes, const Fram CommPhyHeader pktPhyHeader; HeaderConverter::ConvertNetToHost(framePhyHeader, pktPhyHeader); // Restore to host endian - pktPhyHeader.packetLen = pieceTotalLen; - pktPhyHeader.checkSum = 0; // The sum value need to be recalculate - pktPhyHeader.packetType |= PACKET_TYPE_FRAGMENTED; // Set the FragmentedFlag bit - pktPhyHeader.paddingLen = alignedPieceFragLen - pieceFragLen; // The former is always larger than latter + + // The sum value need to be recalculated, and the packet is fragmented. + // The alignedFragLen is always larger than pieceFragLen + FillPhyHeaderLenInfo(pktPhyHeader, pieceTotalLen, 0, PACKET_TYPE_FRAGMENTED, alignedFragLen - pieceFragLen); HeaderConverter::ConvertHostToNet(pktPhyHeader, pktPhyHeader); CommPhyOptHeader pktPhyOptHeader = {static_cast(fragmentInfo.splitLength + sizeof(CommPhyHeader)), diff --git a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp index 2d44ee6c7..d79127f57 100644 --- a/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp +++ b/services/distributeddataservice/libs/distributeddb/interfaces/src/relational/relational_store_delegate_impl.cpp @@ -57,7 +57,7 @@ DBStatus RelationalStoreDelegateImpl::CreateDistributedTable(const std::string & int errCode = conn_->CreateDistributedTable(tableName); if (errCode != E_OK) { - LOGW("[RelationalStore Delegate] Create Distributed table failed:%d", errCode); + LOGE("[RelationalStore Delegate] Create Distributed table failed:%d", errCode); return TransferDBErrno(errCode); } return OK; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp index 4c6a0fc53..5a12f0a13 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp @@ -519,7 +519,6 @@ int DatabaseOper::ClearImportTempFile(const KvDBProperties &property) const std::string exportBackupDir = workDir + "/" + dbSubDir + DBConstant::PATH_POSTFIX_UNPACKED; DBCommon::RemoveAllFilesOfDirectory(exportBackupDir); - LOGI("Clear the files while import"); if (isOriKeepFileExist && isBakKeepFileExist) { LOGE("Origin and backup file shouldn't exist concurrently"); } @@ -556,7 +555,6 @@ int DatabaseOper::ClearExportedTempFiles(const KvDBProperties &property) const int dbType = property.GetIntProp(KvDBProperties::DATABASE_TYPE, KvDBProperties::LOCAL_TYPE); std::string dbSubDir = KvDBProperties::GetStoreSubDirectory(dbType); std::string backupDir = workDir + "/" + dbSubDir + DBConstant::PATH_POSTFIX_EXPORT_BACKUP; - LOGI("Remove the exported files."); errCode = DBCommon::RemoveAllFilesOfDirectory(backupDir); if (errCode != E_OK) { LOGE("Remove the exported backup dir failed"); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp index bc77775f8..55c749d27 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_object.cpp @@ -22,10 +22,6 @@ namespace DistributedDB { namespace { const int INVALID_LIMIT = INT_MAX; const int LIMIT_FIELD_VALUE_SIZE = 2; -bool IsNeedCheckEqualFormat(SymbolType type) -{ - return type == COMPARE_SYMBOL || type == RELATIONAL_SYMBOL || type == RANGE_SYMBOL; -} } QueryObject::QueryObject() @@ -212,45 +208,63 @@ int QueryObject::ParseQueryObjNodes() int QueryObject::ParseNode(const std::list::iterator &iter) { - SymbolType symbolType = SqliteQueryHelper::GetSymbolType(iter->operFlag); // The object is newly instantiated in the connection, and there is no reentrancy problem. - if (symbolType == PREFIXKEY_SYMBOL && hasPrefixKey_) { - LOGE("Only filter by prefix key once!!"); + if (!iter->IsValid()) { return -E_INVALID_QUERY_FORMAT; } - if (iter->operFlag == QueryObjType::OPER_ILLEGAL || iter->type == QueryValueType::VALUE_TYPE_INVALID) { - return -E_INVALID_QUERY_FORMAT; - } else if (IsNeedCheckEqualFormat(symbolType)) { - return CheckEqualFormat(iter); - } else if (symbolType == LINK_SYMBOL) { - return CheckLinkerFormat(iter); - } else if (iter->operFlag == QueryObjType::LIMIT) { - hasLimit_ = true; - if (iter->fieldValue.size() == LIMIT_FIELD_VALUE_SIZE) { - limit_ = iter->fieldValue[0].integerValue; - offset_ = iter->fieldValue[1].integerValue; - } - return CheckLimitFormat(iter); - } else if (iter->operFlag == QueryObjType::ORDERBY) { - return CheckOrderByFormat(iter); - } else if (symbolType == PREFIXKEY_SYMBOL) { - hasPrefixKey_ = true; - if (prefixKey_.size() > DBConstant::MAX_KEY_SIZE) { - return -E_INVALID_ARGS; - } - } else if (symbolType == SUGGEST_INDEX_SYMBOL) { - return CheckSuggestIndexFormat(iter); - } else if (symbolType == IN_KEYS_SYMBOL) { - if (hasInKeys_) { - LOGE("Only filter by keys in once!!"); - return -E_INVALID_QUERY_FORMAT; + switch (SqliteQueryHelper::GetSymbolType(iter->operFlag)) { + case COMPARE_SYMBOL: + case RELATIONAL_SYMBOL: + case RANGE_SYMBOL: + return CheckEqualFormat(iter); + case LINK_SYMBOL: + return CheckLinkerFormat(iter); + case PREFIXKEY_SYMBOL: { + if (hasPrefixKey_) { + LOGE("Only filter by prefix key once!!"); + return -E_INVALID_QUERY_FORMAT; + } + hasPrefixKey_ = true; + if (prefixKey_.size() > DBConstant::MAX_KEY_SIZE) { + return -E_INVALID_ARGS; + } + return E_OK; } - int errCode = CheckInKeys(); - if (errCode != E_OK) { - return errCode; + case SUGGEST_INDEX_SYMBOL: + return CheckSuggestIndexFormat(iter); + case IN_KEYS_SYMBOL: { + if (hasInKeys_) { + LOGE("Only filter by keys in once!!"); + return -E_INVALID_QUERY_FORMAT; + } + int errCode = CheckInKeys(); + if (errCode != E_OK) { + return errCode; + } + hasInKeys_ = true; + return E_OK; } - hasInKeys_ = true; + default: + return ParseNodeByOperFlag(iter); + } + return E_OK; +} + +int QueryObject::ParseNodeByOperFlag(const std::list::iterator &iter) +{ + switch (iter->operFlag) { + case QueryObjType::LIMIT: + hasLimit_ = true; + if (iter->fieldValue.size() == LIMIT_FIELD_VALUE_SIZE) { + limit_ = iter->fieldValue[0].integerValue; + offset_ = iter->fieldValue[1].integerValue; + } + return CheckLimitFormat(iter); + case QueryObjType::ORDERBY: + return CheckOrderByFormat(iter); + default: + return E_OK; } return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp index cd4492dc3..90a535bec 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/query_sync_object.cpp @@ -169,15 +169,11 @@ std::string QuerySyncObject::GetIdentify() const (void)parcel.WriteVectorChar(key); } // QUERY_SYNC_OBJECT_VERSION_1 end. - if (parcel.IsError()) { - return std::string(); - } - std::vector hashBuff; - int errCode = DBCommon::CalcValueHash(buff, hashBuff); - if (errCode != E_OK) { + if (parcel.IsError() || DBCommon::CalcValueHash(buff, hashBuff) != E_OK) { return std::string(); } + return DBCommon::VectorToHexString(hashBuff); } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp index be2cc3b9e..c43ef227d 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp @@ -93,7 +93,6 @@ int SQLiteRelationalStoreConnection::StartTransaction() return errCode; } - LOGD("[RelationalConnection] Start transaction finish."); writeHandle_ = handle; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp index 70d7cec2c..f0ff27eed 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_database_upgrader.cpp @@ -188,8 +188,8 @@ int SQLiteSingleVerDatabaseUpgrader::UpgradeFromDatabaseVersion(int version) { std::vector sqls; bool isCreateUpgradeFile = false; - LOGI("[SqlSingleUp]version=%d, metaSplit[%d], secLabel[%d], secFlag[%d]", - version, isMetaUpgrade_, secOpt_.securityLabel, secOpt_.securityFlag); + LOGI("[SqlSingleUp] metaSplit[%d], secLabel[%d], secFlag[%d]", + isMetaUpgrade_, secOpt_.securityLabel, secOpt_.securityFlag); SetUpgradeSqls(version, sqls, isCreateUpgradeFile); for (const auto &item : sqls) { int errCode = SQLiteUtils::ExecuteRawSQL(db_, item); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp index 7a75c0807..69c31c089 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store.cpp @@ -148,7 +148,8 @@ namespace { size_t appendLen) { bool reachThreshold = false; - for (size_t i = 0, blockSize = 0; !reachThreshold && i < dataItems.size(); i++) { + size_t blockSize = 0; + for (size_t i = 0; !reachThreshold && i < dataItems.size(); i++) { blockSize += SQLiteSingleVerStorageExecutor::GetDataItemSerialSize(dataItems[i], appendLen); reachThreshold = (blockSize >= dataSizeInfo.blockSize * DBConstant::QUERY_SYNC_THRESHOLD); } @@ -1248,6 +1249,7 @@ int SQLiteSingleVerNaturalStore::SaveSyncItems(const QueryObject &query, std::ve ReleaseHandle(handle); return errCode; } + bool isPermitForceWrite = !(GetDbProperties().GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false)); errCode = handle->CheckDataWithQuery(query, dataItems, deviceInfo); if (errCode != E_OK) { goto END; @@ -1260,7 +1262,7 @@ int SQLiteSingleVerNaturalStore::SaveSyncItems(const QueryObject &query, std::ve if (item.neglect) { // Do not save this record if it is neglected continue; } - errCode = handle->SaveSyncDataItem(item, deviceInfo, maxTimestamp, commitData); + errCode = handle->SaveSyncDataItem(item, deviceInfo, maxTimestamp, commitData, isPermitForceWrite); if (errCode != E_OK && errCode != -E_NOT_FOUND) { break; } @@ -1608,7 +1610,7 @@ int SQLiteSingleVerNaturalStore::GetSchema(SchemaObject &schema) const std::string schemaValue(value.begin(), value.end()); errCode = schema.ParseFromSchemaString(schemaValue); } else { - LOGI("[SqlSinStore][GetSchema] Get schema from db failed or no schema=%d.", errCode); + LOGI("[SqlSinStore] Get schema error:%d.", errCode); } ReleaseHandle(handle); return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp index c5abe7bc4..54234478d 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_natural_store_connection.cpp @@ -375,12 +375,7 @@ int SQLiteSingleVerNaturalStoreConnection::Pragma(int cmd, void *parameter) if (parameter == nullptr) { return -E_INVALID_ARGS; } - if (static_cast(parameter)->deviceID == "") { - return -E_INVALID_ARGS; - } - static_cast(parameter)->deviceIdentifier = - DBCommon::TransferHashString(static_cast(parameter)->deviceID); - break; + return CalcHashDevID(*(static_cast(parameter))); } case PRAGMA_GET_DEVICE_IDENTIFIER_OF_ENTRY: return GetDeviceIdentifier(static_cast(parameter)); @@ -1263,7 +1258,6 @@ int SQLiteSingleVerNaturalStoreConnection::StartTransactionInCacheMode() return errCode; } - LOGD("[SingleVerConnection] Start transaction finish in cache mode."); writeHandle_ = handle; transactionEntrySize_ = 0; return E_OK; @@ -1306,7 +1300,6 @@ int SQLiteSingleVerNaturalStoreConnection::StartTransactionNormally() return errCode; } - LOGD("[SingleVerConnection] Start transaction finish."); writeHandle_ = handle; transactionEntrySize_ = 0; return E_OK; @@ -1324,7 +1317,7 @@ void SQLiteSingleVerNaturalStoreConnection::InitConflictNotifiedFlag() if (kvDB_->GetRegisterFunctionCount(CONFLICT_SINGLE_VERSION_NS_NATIVE_ALL) != 0) { conflictFlag |= static_cast(SQLITE_GENERAL_NS_NATIVE_ALL); } - LOGD("[SingleVer][InitConflictNotifiedFlag] conflictFlag Flag: %u", conflictFlag); + committedData_->SetConflictedNotifiedFlag(static_cast(conflictFlag)); } @@ -1334,7 +1327,6 @@ int SQLiteSingleVerNaturalStoreConnection::CommitInner() int errCode = writeHandle_->Commit(); ReleaseExecutor(writeHandle_); - LOGD("Commit transaction finish."); transactionEntrySize_ = 0; if (!isCacheOrMigrating) { @@ -1356,7 +1348,6 @@ int SQLiteSingleVerNaturalStoreConnection::CommitInner() int SQLiteSingleVerNaturalStoreConnection::RollbackInner() { int errCode = writeHandle_->Rollback(); - LOGD("Rollback transaction finish."); transactionEntrySize_ = 0; currentMaxTimeStamp_ = 0; if (!IsExtendedCacheDBMode()) { @@ -1372,7 +1363,7 @@ SQLiteSingleVerStorageExecutor *SQLiteSingleVerNaturalStoreConnection::GetExecut SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { errCode = -E_NOT_INIT; - LOGE("[SingleVerConnection] Kvstore is null, get executor failed! errCode = [%d]", errCode); + LOGE("[SingleVerConnection] the store is null"); return nullptr; } return naturalStore->GetHandle(isWrite, errCode); @@ -1382,7 +1373,7 @@ bool SQLiteSingleVerNaturalStoreConnection::IsCacheDBMode() const { SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { - LOGE("[SingleVerConnection] natural store is null in IsCacheDBMode."); + LOGE("[SingleVerConnection] the store is null"); return false; } return naturalStore->IsCacheDBMode(); @@ -1392,7 +1383,7 @@ bool SQLiteSingleVerNaturalStoreConnection::IsExtendedCacheDBMode() const { SQLiteSingleVerNaturalStore *naturalStore = GetDB(); if (naturalStore == nullptr) { - LOGE("[SingleVerConnection] natural store is nullptr in IsExtendedCacheDBMode."); + LOGE("[SingleVerConnection] the store is null"); return false; } return naturalStore->IsExtendedCacheDBMode(); @@ -1764,5 +1755,14 @@ bool SQLiteSingleVerNaturalStoreConnection::CheckLogOverLimit(SQLiteSingleVerSto return result; } +int SQLiteSingleVerNaturalStoreConnection::CalcHashDevID(PragmaDeviceIdentifier &pragmaDev) +{ + if (pragmaDev.deviceID.empty()) { + return -E_INVALID_ARGS; + } + pragmaDev.deviceIdentifier = DBCommon::TransferHashString(pragmaDev.deviceID); + return E_OK; +} + DEFINE_OBJECT_TAG_FACILITIES(SQLiteSingleVerNaturalStoreConnection) } \ No newline at end of file diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp index 7d85f0743..3ca30a82b 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_relational_storage_executor.cpp @@ -625,14 +625,13 @@ int SQLiteSingleVerRelationalStorageExecutor::PrepareForSavingLog(const QueryObj int errCode = SQLiteUtils::GetStatement(dbHandle_, sql, logStmt); if (errCode != E_OK) { LOGE("[info statement] Get log statement fail! errCode:%d", errCode); - return -E_INVALID_QUERY_FORMAT; + return errCode; } std::string selectSql = "select " + columnList + " from " + tableName + " where hash_key = ? and device = ?;"; errCode = SQLiteUtils::GetStatement(dbHandle_, selectSql, queryStmt); if (errCode != E_OK) { SQLiteUtils::ResetStatement(logStmt, true, errCode); LOGE("[info statement] Get query statement fail! errCode:%d", errCode); - return -E_INVALID_QUERY_FORMAT; } return errCode; } @@ -654,7 +653,6 @@ int SQLiteSingleVerRelationalStorageExecutor::PrepareForSavingData(const QueryOb int errCode = SQLiteUtils::GetStatement(dbHandle_, sql, statement); if (errCode != E_OK) { LOGE("[info statement] Get saving data statement fail! errCode:%d", errCode); - errCode = -E_INVALID_QUERY_FORMAT; } return errCode; } @@ -718,8 +716,8 @@ int SQLiteSingleVerRelationalStorageExecutor::DeleteSyncDataItem(const DataItem "WHERE hash_key=? AND device=? AND flag&0x01=0);"; int errCode = SQLiteUtils::GetStatement(dbHandle_, sql, stmt); if (errCode != E_OK) { - LOGE("[DeleteSyncDataItem] Get statement fail!"); - return -E_INVALID_QUERY_FORMAT; + LOGE("[DeleteSyncDataItem] Get statement fail!, errCode:%d", errCode); + return errCode; } } diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp index 92e7386bb..85714b270 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_engine.cpp @@ -241,6 +241,19 @@ int SQLiteSingleVerStorageEngine::MigrateSyncData(SQLiteSingleVerStorageExecutor LOGD("Begin migrate sync data, need migrate version[%llu]", GetCacheRecordVersion() - 1); uint64_t curMigrateVer = 0; // The migration process is asynchronous and continuous NotifyMigrateSyncData syncData; + auto kvdbManager = KvDBManager::GetInstance(); + if (kvdbManager != nullptr) { + auto identifier = GetIdentifier(); + auto kvdb = kvdbManager->FindKvDB(identifier); + if (kvdb != nullptr) { + auto kvStore = static_cast(kvdb); + syncData.isPermitForceWrite = + !(kvStore->GetDbProperties().GetBoolProp(KvDBProperties::SYNC_DUAL_TUPLE_MODE, false)); + RefObject::DecObjRef(kvdb); + } else { + LOGE("[SingleVerEngine] kvdb is null."); + } + } // cache atomic version represents version of cacheDb input next time while (curMigrateVer < GetCacheRecordVersion()) { errCode = MigrateSyncDataByVersion(handle, syncData, curMigrateVer); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp index ae9970dd0..07257fcf1 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor.cpp @@ -141,10 +141,8 @@ int SQLiteSingleVerStorageExecutor::GetKvData(SingleVerDataType type, const Key // get timestamp if (type == SingleVerDataType::LOCAL_TYPE) { timeStamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_LOCAL_TIME_INDEX)); - LOGD("[SingleVerExe][GetKv] Timestamp from local is %llu", timeStamp); } else if (type == SingleVerDataType::SYNC_TYPE) { timeStamp = static_cast(sqlite3_column_int64(statement, GET_KV_RES_SYNC_TIME_INDEX)); - LOGD("[SingleVerExe][GetKv] Timestamp from sync is %llu", timeStamp); } END: @@ -418,7 +416,6 @@ void SQLiteSingleVerStorageExecutor::InitCurrentMaxStamp(TimeStamp &maxStamp) errCode = SQLiteUtils::StepWithRetry(statement, isMemDb_); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { maxStamp = static_cast(sqlite3_column_int64(statement, 0)); // get the first column - LOGD("Max time stamp is %llu", maxStamp); } SQLiteUtils::ResetStatement(statement, true, errCode); } @@ -1216,7 +1213,7 @@ int SQLiteSingleVerStorageExecutor::SaveSyncDataToDatabase(const DataItem &dataI } DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataItem, - const DataItem &itemGet, const std::string &devName, bool isHashKeyExisted) + const DataItem &itemGet, const std::string &devName, bool isHashKeyExisted, bool isPermitForceWrite) { DataOperStatus status; status.isDeleted = ((dataItem.flag & DataItem::DELETE_FLAG) == DataItem::DELETE_FLAG || @@ -1229,7 +1226,8 @@ DataOperStatus SQLiteSingleVerStorageExecutor::JudgeSyncSaveType(DataItem &dataI } std::string deviceName = DBCommon::TransferHashString(devName); if (itemGet.writeTimeStamp >= dataItem.writeTimeStamp) { - if ((!deviceName.empty()) && (itemGet.dev == deviceName)) { + // for multi user mode, no permit to forcewrite + if ((!deviceName.empty()) && (itemGet.dev == deviceName) && isPermitForceWrite) { LOGI("Force overwrite the data:%llu vs %llu", itemGet.writeTimeStamp, dataItem.writeTimeStamp); status.isDefeated = false; dataItem.writeTimeStamp = itemGet.writeTimeStamp + 1; @@ -1282,7 +1280,7 @@ namespace { } int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem &dataItem, - const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify) + const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify, bool isPermitForceWrite) { // Check sava data existed info int errCode = GetSyncDataItemPre(dataItem, notify.getData, notify.hashKey); @@ -1305,7 +1303,8 @@ int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem return ResetSaveSyncStatements(-E_IGNORE_DATA); } - notify.dataStatus = JudgeSyncSaveType(dataItem, notify.getData, deviceInfo.deviceName, isHashKeyExisted); + notify.dataStatus = JudgeSyncSaveType(dataItem, notify.getData, deviceInfo.deviceName, isHashKeyExisted, + isPermitForceWrite); InitCommitNotifyDataKeyStatus(notify.committedData, notify.hashKey, notify.dataStatus); // Nonexistent data, but deleted by local. @@ -1337,13 +1336,13 @@ int SQLiteSingleVerStorageExecutor::PrepareForNotifyConflictAndObserver(DataItem } int SQLiteSingleVerStorageExecutor::SaveSyncDataItem(DataItem &dataItem, const DeviceInfo &deviceInfo, - TimeStamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData) + TimeStamp &maxStamp, SingleVerNaturalStoreCommitNotifyData *committedData, bool isPermitForceWrite) { NotifyConflictAndObserverData notify = { .committedData = committedData }; - int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify); + int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify, isPermitForceWrite); if (errCode != E_OK) { if (errCode == -E_IGNORE_DATA) { errCode = E_OK; @@ -2160,7 +2159,6 @@ uint64_t SQLiteSingleVerStorageExecutor::GetLogFileSize() const if (result != E_OK) { return 0; } - LOGI("The log file size is %llu", fileSize); return fileSize; } } // namespace DistributedDB diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp index 9559b8fb4..0c2d44754 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_single_ver_storage_executor_cache.cpp @@ -265,7 +265,8 @@ int SQLiteSingleVerStorageExecutor::MigrateDataItem(DataItem &dataItem, NotifyMi // Put or delete. Prepare notify data here. NotifyConflictAndObserverData notify; notify.committedData = syncData.committedData; - int errCode = PutIntoConflictAndCommitForMigrateCache(dataItem, {dataItem.dev.empty(), dataItem.dev}, notify); + int errCode = PutIntoConflictAndCommitForMigrateCache(dataItem, {dataItem.dev.empty(), dataItem.dev}, notify, + syncData.isPermitForceWrite); if (errCode != E_OK) { ResetForMigrateCacheData(); LOGE("PutIntoConflictAndCommitForMigrateCache failed, errCode = %d", errCode); @@ -755,9 +756,9 @@ int SQLiteSingleVerStorageExecutor::BindLocalDataInCacheMode(sqlite3_stmt *state } int SQLiteSingleVerStorageExecutor::PutIntoConflictAndCommitForMigrateCache(DataItem &dataItem, - const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify) + const DeviceInfo &deviceInfo, NotifyConflictAndObserverData ¬ify, bool isPermitForceWrite) { - int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify); + int errCode = PrepareForNotifyConflictAndObserver(dataItem, deviceInfo, notify, isPermitForceWrite); if (errCode != E_OK) { errCode = (errCode == -E_NOT_FOUND ? E_OK : errCode); if (errCode == -E_IGNORE_DATA) { diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp index 60f5911d1..dd7935f42 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp @@ -724,6 +724,41 @@ bool CheckFieldName(const std::string &fieldName) } } +int SetFieldInfo(sqlite3_stmt *statement, TableInfo &table) +{ + FieldInfo field; + field.SetColumnId(sqlite3_column_int(statement, 0)); // 0 means column id index + + std::string tmpString; + (void) SQLiteUtils::GetColumnTextValue(statement, 1, tmpString); // 1 means column name index + if (!CheckFieldName(tmpString)) { + LOGE("[AnalysisSchema] unsupported field name."); + return -E_NOT_SUPPORT; + } + field.SetFieldName(tmpString); + + (void) SQLiteUtils::GetColumnTextValue(statement, 2, tmpString); // 2 means datatype index + field.SetDataType(tmpString); + + field.SetNotNull(static_cast(sqlite3_column_int64(statement, 3))); // 3 means whether null index + + (void) SQLiteUtils::GetColumnTextValue(statement, 4, tmpString); // 4 means default value index + if (!tmpString.empty()) { + field.SetDefaultValue(tmpString); + } + + if (sqlite3_column_int64(statement, 5) != 0) { // 5 means primary key index + if (!table.GetPrimaryKey().empty()) { + // Primary key is already set, usually because the primary key has multiple fields, not support + LOGE("[AnalysisSchema] Not support for composite primary key"); + return -E_NOT_SUPPORT; + } + table.SetPrimaryKey(field.GetFieldName()); + } + table.AddField(field); + return E_OK; +} + int AnalysisSchemaFieldDefine(sqlite3 *db, const std::string &tableName, TableInfo &table) { std::string sql = "pragma table_info(" + tableName + ")"; @@ -733,39 +768,17 @@ int AnalysisSchemaFieldDefine(sqlite3 *db, const std::string &tableName, TableIn LOGE("[AnalysisSchema] Prepare the analysis schema field statement error:%d", errCode); return errCode; } + do { errCode = SQLiteUtils::StepWithRetry(statement); if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_DONE)) { errCode = E_OK; break; } else if (errCode == SQLiteUtils::MapSQLiteErrno(SQLITE_ROW)) { - FieldInfo field; - std::string tmpString; - - field.SetColumnId(sqlite3_column_int(statement, 0)); // 0 means column id index - - (void) SQLiteUtils::GetColumnTextValue(statement, 1, tmpString); // 1 means column name index - if (!CheckFieldName(tmpString)) { - errCode = -E_NOT_SUPPORT; - LOGE("[AnalysisSchema] unsupported field name."); + errCode = SetFieldInfo(statement, table); + if (errCode != E_OK) { break; } - field.SetFieldName(tmpString); - - (void) SQLiteUtils::GetColumnTextValue(statement, 2, tmpString); // 2 means datatype index - field.SetDataType(tmpString); - - field.SetNotNull(static_cast(sqlite3_column_int64(statement, 3))); // 3 means whether null index - - (void) SQLiteUtils::GetColumnTextValue(statement, 4, tmpString); // 4 means default value index - if (!tmpString.empty()) { - field.SetDefaultValue(tmpString); - } - - if (sqlite3_column_int64(statement, 5)) { // 5 means primary key index - table.SetPrimaryKey(field.GetFieldName()); - } - table.AddField(field); } else { LOGW("[AnalysisSchema] Step for the analysis schema field failed:%d", errCode); break; @@ -916,7 +929,6 @@ int SQLiteUtils::GetVersion(sqlite3 *db, int &version) if (sqlite3_step(statement) == SQLITE_ROW) { // Get pragma user_version at first column version = sqlite3_column_int(statement, 0); - LOGD("[SqlUtil][GetVer] db version=%d", version); } else { LOGE("[SqlUtil][GetVer] Get db user_version failed."); errCode = SQLiteUtils::MapSQLiteErrno(SQLITE_ERROR); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp index a45b782b9..007a87bf3 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/storage_engine.cpp @@ -307,7 +307,7 @@ EngineState StorageEngine::GetEngineState() const void StorageEngine::SetEngineState(EngineState state) { - LOGI("Set storage engine state to [%d]!", state); + LOGI("Storage engine state to [%d]!", state); engineState_ = state; } @@ -361,7 +361,6 @@ void StorageEngine::AddStorageExecutor(StorageExecutor *handle) } else { readIdleList_.push_back(handle); } - LOGD("add [%d] storage executor to handle pool.", handle->GetWritable()); } void StorageEngine::CloseExecutor() @@ -412,8 +411,8 @@ StorageExecutor *StorageEngine::FetchStorageExecutor(bool isWrite, std::list SINGLE_VER_STORE_VERSION_CURRENT) { LOGE("[SingleUp][Upgrade] DbVersion=%d is newer.", dbVersion_); return -E_VERSION_NOT_SUPPORT; } - LOGI("[SingleUp][Upgrade] DbVersion=%d.", dbVersion_); - + LOGI("[SingleUp][Upgrade] from %d to %d.", dbVersion_, SINGLE_VER_STORE_VERSION_CURRENT); errCode = BeginUpgrade(); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] Begin fail, errCode=%d.", errCode); + LOGE("[SingleUp][Upgrade] Begin error:%d.", errCode); return errCode; } errCode = ExecuteUpgrade(); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] Execute fail, errCode=%d.", errCode); + LOGE("[SingleUp][Upgrade] Execute error:%d.", errCode); EndUpgrade(false); return errCode; } @@ -48,7 +46,7 @@ int SingleVerDatabaseUpgrader::Upgrade() if (dbVersion_ < SINGLE_VER_STORE_VERSION_CURRENT) { errCode = SetDatabaseVersion(SINGLE_VER_STORE_VERSION_CURRENT); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] SetVersion fail, errCode=%d.", errCode); + LOGE("[SingleUp][Upgrade] SetVersion error:%d.", errCode); EndUpgrade(false); return errCode; } @@ -56,11 +54,10 @@ int SingleVerDatabaseUpgrader::Upgrade() errCode = EndUpgrade(true); if (errCode != E_OK) { - LOGE("[SingleUp][Upgrade] End fail, errCode=%d.", errCode); + LOGE("[SingleUp][Upgrade] End error:%d.", errCode); return errCode; } - LOGI("[SingleUp][Upgrade] Exit Successfully."); return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp index 9588a3a24..514a79354 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp @@ -133,7 +133,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const len += Parcel::GetUInt32Len(); // softwareVersion_ uint32_t schemLen = Parcel::GetStringLen(schema_); if (schemLen == 0) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] schemLen error!"); + LOGE("[AbilitySyncRequestPacket][CalculateLen] schemLen err!"); return 0; } len += schemLen; @@ -145,7 +145,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const // the reason why not 8-byte align is that old version is not 8-byte align // so it is not possible to set 8-byte align for high version. if (len > INT32_MAX) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] error length=%llu", len); + LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%llu", len); return 0; } return len; @@ -286,7 +286,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += Parcel::GetIntLen(); uint32_t schemLen = Parcel::GetStringLen(schema_); if (schemLen == 0) { - LOGE("[AbilitySyncAckPacket][CalculateLen] schemLen error!"); + LOGE("[AbilitySyncAckPacket][CalculateLen] schemLen err!"); return 0; } len += schemLen; @@ -299,7 +299,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += DbAbility::CalculateLen(dbAbility_); // dbAbility_ len += SchemaNegotiate::CalculateParcelLen(relationalSyncOpinion_); if (len > INT32_MAX) { - LOGE("[AbilitySyncAckPacket][CalculateLen] error length=%llu", len); + LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%llu", len); return 0; } return len; @@ -344,7 +344,6 @@ int AbilitySync::Initialize(ICommunicator *inCommunicator, ISyncInterface *inSto std::shared_ptr &inMetadata, const std::string &deviceId) { if (inCommunicator == nullptr || inStorage == nullptr || deviceId.empty() || inMetadata == nullptr) { - LOGE("[AbilitySync][Initialize] args error"); return -E_INVALID_ARGS; } communicator_ = inCommunicator; @@ -360,18 +359,16 @@ int AbilitySync::SyncStart(uint32_t sessionId, uint32_t sequenceId, uint16_t rem AbilitySyncRequestPacket packet; int errCode = SetAbilityRequestBodyInfo(packet, remoteCommunicatorVersion); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] set AbilityRequestBodyInfo error, errCode=%d", errCode); return errCode; } Message *message = new (std::nothrow) Message(ABILITY_SYNC_MESSAGE); if (message == nullptr) { - LOGE("[AbilitySync][SyncStart] message is nullptr"); return -E_OUT_OF_MEMORY; } message->SetMessageType(TYPE_REQUEST); errCode = message->SetCopiedObject<>(packet); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] SetCopiedObject failed, errCode=%d", errCode); + LOGE("[AbilitySync][SyncStart] SetCopiedObject failed, err %d", errCode); delete message; message = nullptr; return errCode; @@ -383,7 +380,7 @@ int AbilitySync::SyncStart(uint32_t sessionId, uint32_t sequenceId, uint16_t rem SetSendConfig(deviceId_, false, SEND_TIME_OUT, conf); errCode = communicator_->SendMessage(deviceId_, message, conf, handler); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] SendPacket failed, errCode=%d", errCode); + LOGE("[AbilitySync][SyncStart] SendPacket failed, err %d", errCode); delete message; message = nullptr; } @@ -394,12 +391,10 @@ int AbilitySync::AckRecv(const Message *message, ISyncTaskContext *context) { int errCode = AckMsgCheck(message, context); if (errCode != E_OK) { - LOGE("[AbilitySync][AckRecv] AckMsgCheck error, errCode=%d", errCode); return errCode; } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][AckRecv] get packet is nullptr"); return -E_INVALID_ARGS; } uint32_t remoteSoftwareVersion = packet->GetSoftwareVersion(); @@ -423,18 +418,16 @@ int AbilitySync::AckRecv(const Message *message, ISyncTaskContext *context) int AbilitySync::RequestRecv(const Message *message, ISyncTaskContext *context) { if (message == nullptr || context == nullptr) { - LOGE("[AbilitySync][RequestRecv] message or context is nullptr"); return -E_INVALID_ARGS; } const AbilitySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][RequestRecv] get packet is nullptr"); return -E_INVALID_ARGS; } if (packet->GetSendCode() == -E_VERSION_NOT_SUPPORT) { AbilitySyncAckPacket ackPacket; (void)SendAck(message, -E_VERSION_NOT_SUPPORT, false, ackPacket); - LOGI("[AbilitySync][RequestRecv] version can not support, remote version = %u", packet->GetProtocolVersion()); + LOGI("[AbilitySync][RequestRecv] version can not support, remote version is %u", packet->GetProtocolVersion()); return -E_VERSION_NOT_SUPPORT; } @@ -451,7 +444,6 @@ int AbilitySync::RequestRecv(const Message *message, ISyncTaskContext *context) int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context) { if (message == nullptr || context == nullptr) { - LOGE("[AbilitySync][AckNotifyRecv] message or context is nullptr"); return -E_INVALID_ARGS; } if (message->GetErrorNo() == E_FEEDBACK_UNKNOWN_MESSAGE) { @@ -461,12 +453,11 @@ int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][AckNotifyRecv] get packet is nullptr"); return -E_INVALID_ARGS; } int errCode = packet->GetAckCode(); if (errCode != E_OK) { - LOGE("[AbilitySync][AckNotifyRecv] received a errCode=%d", errCode); + LOGE("[AbilitySync][AckNotifyRecv] received a errCode %d", errCode); return errCode; } std::string schema = packet->GetSchema(); @@ -500,24 +491,22 @@ bool AbilitySync::SecLabelCheck(const AbilitySyncRequestPacket *packet) const int32_t remoteSecLabel = packet->GetSecLabel(); int32_t remoteSecFlag = packet->GetSecFlag(); if (remoteSecLabel == NOT_SURPPORT_SEC_CLASSIFICATION || remoteSecLabel == SecurityLabel::NOT_SET) { - LOGI("[AbilitySync][RequestRecv] remoteSecLabel not surpport or not set"); return true; } SecurityOption option; int errCode = (static_cast(storageInterface_))->GetSecurityOption(option); - LOGI("[AbilitySync][RequestRecv] local label=%d, flag=%d, errCode=%d", - option.securityLabel, option.securityFlag, errCode); + LOGI("[AbilitySync][RequestRecv] local l:%d, f:%d, errCode:%d", option.securityLabel, option.securityFlag, errCode); if (errCode == -E_NOT_SUPPORT || option.securityLabel == SecurityLabel::NOT_SET) { return true; } if (remoteSecLabel == FAILED_GET_SEC_CLASSIFICATION || errCode != E_OK) { - LOGE("[AbilitySync][RequestRecv] check error remoteLable=%d, errCode=%d", remoteSecLabel, errCode); + LOGE("[AbilitySync][RequestRecv] check error remoteL:%d, errCode:%d", remoteSecLabel, errCode); return false; } if (remoteSecLabel == option.securityLabel) { return true; } else { - LOGE("[AbilitySync][RequestRecv] check error remote:lable=%d,flag=%d, local:lable=%d,flag=%d", + LOGE("[AbilitySync][RequestRecv] check error remote:%d , %d local:%d , %d", remoteSecLabel, remoteSecFlag, option.securityLabel, option.securityFlag); return false; } @@ -551,7 +540,6 @@ int AbilitySync::HandleVersionV3AckSchemaParam(const AbilitySyncAckPacket *recvP AbilitySyncAckPacket &sendPacket, ISyncTaskContext *context, bool sendOpinion) const { if (IsSingleRelationalVer()) { - LOGI("[AbilitySync][HandleVersionV3AckSchemaParam] Single Relational Ver"); return HandleRelationAckSchemaParam(recvPacket, sendPacket, context, sendOpinion); } HandleKvAckSchemaParam(recvPacket, context, sendPacket); @@ -569,7 +557,7 @@ void AbilitySync::GetPacketSecOption(SecurityOption &option) const LOGE("[AbilitySync][SyncStart] GetSecOpt not surpport sec classification"); option.securityLabel = NOT_SURPPORT_SEC_CLASSIFICATION; } else if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetSecOpt errCode=%d", errCode); + LOGE("[AbilitySync][SyncStart] GetSecOpt errCode:%d", errCode); option.securityLabel = FAILED_GET_SEC_CLASSIFICATION; } } @@ -588,7 +576,6 @@ int AbilitySync::RegisterTransformFunc() uint32_t AbilitySync::CalculateLen(const Message *inMsg) { if ((inMsg == nullptr) || (inMsg->GetMessageId() != ABILITY_SYNC_MESSAGE)) { - LOGE("[AbilitySync][CalculateLen] message is nullptr or messageid not true"); return 0; } int errCode; @@ -597,23 +584,23 @@ uint32_t AbilitySync::CalculateLen(const Message *inMsg) case TYPE_REQUEST: errCode = RequestPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] request packet calc length err=%d", errCode); + LOGE("[AbilitySync][CalculateLen] request packet calc length err %d", errCode); } break; case TYPE_RESPONSE: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] ack packet calc length err=%d", errCode); + LOGE("[AbilitySync][CalculateLen] ack packet calc length err %d", errCode); } break; case TYPE_NOTIFY: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] ack packet calc length err=%d", errCode); + LOGE("[AbilitySync][CalculateLen] ack packet calc length err %d", errCode); } break; default: - LOGE("[AbilitySync][CalculateLen] message type not support, type=%d", inMsg->GetMessageType()); + LOGE("[AbilitySync][CalculateLen] message type not support, type %d", inMsg->GetMessageType()); break; } return len; @@ -622,7 +609,6 @@ uint32_t AbilitySync::CalculateLen(const Message *inMsg) int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { - LOGE("[AbilitySync][Serialization] buffer or message is nullptr"); return -E_INVALID_ARGS; } @@ -634,7 +620,6 @@ int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message * case TYPE_NOTIFY: return AckPacketSerialization(buffer, length, inMsg); default: - LOGE("[AbilitySync][Serialization] message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -642,7 +627,6 @@ int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message * int AbilitySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { - LOGE("[AbilitySync][DeSerialization] buffer or message is nullptr"); return -E_INVALID_ARGS; } @@ -654,7 +638,6 @@ int AbilitySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message case TYPE_NOTIFY: return AckPacketDeSerialization(buffer, length, inMsg); default: - LOGE("[AbilitySync][DeSerialization] message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -663,7 +646,6 @@ int AbilitySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { const AbilitySyncRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][RequestPacketCalculateLen] get packet is nullptr"); return -E_INVALID_ARGS; } @@ -675,7 +657,6 @@ int AbilitySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { const AbilitySyncAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][AckPacketCalculateLen] get packet is nullptr"); return -E_INVALID_ARGS; } @@ -687,7 +668,6 @@ int AbilitySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, co { const AbilitySyncRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { - LOGE("[AbilitySync][RequestPacketSerialization]get packet is nullptr or length error"); return -E_INVALID_ARGS; } @@ -702,7 +682,6 @@ int AbilitySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, co parcel.WriteUInt64(packet->GetDbCreateTime()); int errCode = DbAbility::Serialize(parcel, packet->GetDbAbility()); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][RequestPacketSerialization] Serialize error errCode=%d", errCode); return -E_PARSE_FAIL; } return E_OK; @@ -712,7 +691,6 @@ int AbilitySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const { const AbilitySyncAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { - LOGE("[AbilitySync][AckPacketSerialization] get packet is nullptr or length error"); return -E_INVALID_ARGS; } @@ -729,12 +707,10 @@ int AbilitySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const parcel.WriteUInt64(packet->GetDbCreateTime()); int errCode = DbAbility::Serialize(parcel, packet->GetDbAbility()); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][AckPacketSerialization] Serialize error errCode=%d", errCode); return -E_PARSE_FAIL; } errCode = SchemaNegotiate::SerializeData(packet->GetRelationalSyncOpinion(), parcel); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][AckPacketSerialization] SerializeData error errCode=%d", errCode); return -E_PARSE_FAIL; } return E_OK; @@ -744,7 +720,6 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le { auto *packet = new (std::nothrow) AbilitySyncRequestPacket(); if (packet == nullptr) { - LOGE("[AbilitySync][RequestPacketDeSerialization] get packet is nullptr"); return -E_OUT_OF_MEMORY; } @@ -757,7 +732,6 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le parcel.ReadUInt32(version); if (parcel.IsError()) { - LOGE("[AbilitySync][RequestPacketDeSerialization] parcel is error"); goto ERROR_OUT; } packet->SetProtocolVersion(version); @@ -765,7 +739,6 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le packet->SetSendCode(-E_VERSION_NOT_SUPPORT); errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { - LOGE("[AbilitySync][RequestPacketDeSerialization] SetExternalObject error errCode=%d", errCode); goto ERROR_OUT; } return errCode; @@ -775,7 +748,6 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le parcel.ReadString(schema); errCode = RequestPacketDeSerializationTailPart(parcel, packet, softwareVersion); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][RequestPacketDeSerialization] RequestPacketDeSerializationTailPart error errCode=%d", errCode); goto ERROR_OUT; } packet->SetSendCode(sendCode); @@ -815,7 +787,7 @@ int AbilitySync::RequestPacketDeSerializationTailPart(Parcel &parcel, AbilitySyn DbAbility remoteDbAbility; int errCode = DbAbility::DeSerialize(parcel, remoteDbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync] request packet DeSerializ failed, errCode=%d", errCode); + LOGE("[AbilitySync] request packet DeSerializ failed."); return errCode; } packet->SetDbAbility(remoteDbAbility); @@ -849,14 +821,14 @@ int AbilitySync::AckPacketDeSerializationTailPart(Parcel &parcel, AbilitySyncAck DbAbility remoteDbAbility; int errCode = DbAbility::DeSerialize(parcel, remoteDbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync] ack packet DeSerializ failed, errCode=%d", errCode); + LOGE("[AbilitySync] ack packet DeSerializ failed."); return errCode; } packet->SetDbAbility(remoteDbAbility); RelationalSyncOpinion relationalSyncOpinion; errCode = SchemaNegotiate::DeserializeData(parcel, relationalSyncOpinion); if (errCode != E_OK) { - LOGE("[AbilitySync] ack packet DeSerializ RelationalSyncOpinion failed, errCode=%d", errCode); + LOGE("[AbilitySync] ack packet DeSerializ RelationalSyncOpinion failed."); return errCode; } packet->SetRelationalSyncOpinion(relationalSyncOpinion); @@ -867,7 +839,6 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length { auto *packet = new (std::nothrow) AbilitySyncAckPacket(); if (packet == nullptr) { - LOGE("[AbilitySync][RequestDeSerialization] get packet is nullptr"); return -E_OUT_OF_MEMORY; } @@ -888,7 +859,6 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length packet->SetAckCode(-E_VERSION_NOT_SUPPORT); errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { - LOGE("[AckPacketDeSerialization] ack packet SetExternalObject failed, errCode=%d", errCode); goto ERROR_OUT; } return errCode; @@ -898,7 +868,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length parcel.ReadString(schema); errCode = AckPacketDeSerializationTailPart(parcel, packet, softwareVersion); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][RequestDeSerialization] DeSerialization failed, errCode=%d", errCode); + LOGE("[AbilitySync][RequestDeSerialization] DeSerialization failed!"); errCode = -E_PARSE_FAIL; goto ERROR_OUT; } @@ -922,7 +892,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin int errCode = (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][SetAbilityRequestBodyInfo] GetDatabaseCreateTimeStamp failed, err=%d", errCode); + LOGE("[AbilitySync][FillAbilityRequest] GetDatabaseCreateTimeStamp failed, err %d", errCode); return errCode; } SecurityOption option; @@ -941,7 +911,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin DbAbility dbAbility; errCode = GetDbAbilityInfo(dbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync][SetAbilityRequestBodyInfo] GetDbAbility failed, err=%d", errCode); + LOGE("[AbilitySync][FillAbilityRequest] GetDbAbility failed, err %d", errCode); return errCode; } // 102 version is forbidden to sync with 103 json-schema or flatbuffer-schema @@ -978,13 +948,13 @@ int AbilitySync::SetAbilityAckBodyInfo(AbilitySyncAckPacket &ackPacket, int ackC errCode = (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err=%d", errCode); + LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err %d", errCode); ackCode = errCode; } DbAbility dbAbility; errCode = GetDbAbilityInfo(dbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync][SetAbilityAckBodyInfo] GetDbAbility failed, err=%d", errCode); + LOGE("[AbilitySync][FillAbilityRequest] GetDbAbility failed, err %d", errCode); return errCode; } ackPacket.SetDbCreateTime(dbCreateTime); @@ -1012,7 +982,6 @@ int AbilitySync::GetDbAbilityInfo(DbAbility &dbAbility) const for (const auto &item : SyncConfig::ABILITYBITS) { errCode = dbAbility.SetAbilityItem(item, SUPPORT_MARK); if (errCode != E_OK) { - LOGE("[AbilitySync][GetDbAbilityInfo] SetAbilityItem failed, err=%d", errCode); return errCode; } } @@ -1022,7 +991,6 @@ int AbilitySync::GetDbAbilityInfo(DbAbility &dbAbility) const int AbilitySync::AckMsgCheck(const Message *message, ISyncTaskContext *context) const { if (message == nullptr || context == nullptr) { - LOGE("[AbilitySync][AckMsgCheck] message or context is nullptr"); return -E_INVALID_ARGS; } if (message->GetErrorNo() == E_FEEDBACK_UNKNOWN_MESSAGE) { @@ -1038,12 +1006,11 @@ int AbilitySync::AckMsgCheck(const Message *message, ISyncTaskContext *context) } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][AckMsgCheck] packet is nullptr"); return -E_INVALID_ARGS; } int ackCode = packet->GetAckCode(); if (ackCode != E_OK) { - LOGE("[AbilitySync][AckMsgCheck] received an errCode=%d", ackCode); + LOGE("[AbilitySync][AckMsgCheck] received an errCode %d", ackCode); context->SetTaskErrCode(ackCode); return ackCode; } @@ -1067,7 +1034,6 @@ int AbilitySync::HandleRequestRecv(const Message *message, ISyncTaskContext *con { const AbilitySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("[AbilitySync][HandleRequestRecv] packet is nullptr"); return -E_INVALID_ARGS; } uint32_t remoteSoftwareVersion = packet->GetSoftwareVersion(); @@ -1102,7 +1068,6 @@ int AbilitySync::SendAck(const Message *message, int ackCode, bool isAckNotify, { int errCode = SetAbilityAckBodyInfo(ackPacket, ackCode, isAckNotify); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SetAbilityAckBodyInfo error errCode=%d", errCode); return errCode; } if (IsSingleRelationalVer()) { @@ -1121,7 +1086,6 @@ int AbilitySync::SendAckWithEmptySchema(const Message *message, int ackCode, AbilitySyncAckPacket ackPacket; int errCode = SetAbilityAckBodyInfo(ackPacket, ackCode, isAckNotify); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAckWithEmptySchema] SetAbilityAckBodyInfo error errCode=%d", errCode); return errCode; } SetAbilityAckSchemaInfo(ackPacket, SchemaObject()); @@ -1137,7 +1101,7 @@ int AbilitySync::SendAck(const Message *inMsg, const AbilitySyncAckPacket &ackPa } int errCode = ackMessage->SetCopiedObject<>(ackPacket); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SetCopiedObject failed, err=%d", errCode); + LOGE("[AbilitySync][SendAck] SetCopiedObject failed, err %d", errCode); delete ackMessage; ackMessage = nullptr; return errCode; @@ -1150,7 +1114,7 @@ int AbilitySync::SendAck(const Message *inMsg, const AbilitySyncAckPacket &ackPa SetSendConfig(deviceId_, false, SEND_TIME_OUT, conf); errCode = communicator_->SendMessage(deviceId_, ackMessage, conf); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SendPacket failed, err=%d", errCode); + LOGE("[AbilitySync][SendAck] SendPacket failed, err %d", errCode); delete ackMessage; ackMessage = nullptr; } @@ -1228,7 +1192,6 @@ int AbilitySync::AckRecvWithHighVersion(const Message *message, ISyncTaskContext AbilitySyncAckPacket ackPacket; int errCode = HandleVersionV3AckSchemaParam(packet, ackPacket, context, true); if (errCode != E_OK) { - LOGE("[AbilitySync][AckRecvWithHighVersion] HandleVersionV3AckSchemaParam failed,errCode=%d", errCode); return errCode; } auto singleVerContext = static_cast(context); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp index 0e2dd38ea..ffb3c0e36 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp @@ -141,7 +141,6 @@ CommitHistorySync::~CommitHistorySync() int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { - LOGE("CommitHistorySync::Serialization buffer is nullptr or error in validity of package."); return -E_MESSAGE_ID_ERROR; } @@ -151,7 +150,6 @@ int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Mes case TYPE_RESPONSE: return AckPacketSerialization(buffer, length, inMsg); default: - LOGE("CommitHistorySync::Serialization message type error."); return -E_MESSAGE_TYPE_ERROR; } } @@ -159,7 +157,6 @@ int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Mes int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { - LOGE("CommitHistorySync::DeSerialization buffer is nullptr or error in validity of package."); return -E_MESSAGE_ID_ERROR; } @@ -169,7 +166,6 @@ int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, M case TYPE_RESPONSE: return AckPacketDeSerialization(buffer, length, inMsg); default: - LOGE("CommitHistorySync::DeSerialization message type error."); return -E_MESSAGE_TYPE_ERROR; } } @@ -177,7 +173,6 @@ int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, M uint32_t CommitHistorySync::CalculateLen(const Message *inMsg) { if (!(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { - LOGE("CommitHistorySync::CalculateLen error in validity of package."); return 0; } @@ -187,14 +182,12 @@ uint32_t CommitHistorySync::CalculateLen(const Message *inMsg) case TYPE_REQUEST: errCode = RequestPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("CommitHistorySync::CalculateLen request packet calculateLen error=%d.", errCode); return 0; } return len; case TYPE_RESPONSE: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("CommitHistorySync::CalculateLen ack packet calculateLen error=%d.", errCode); return 0; } return len; @@ -217,7 +210,6 @@ int CommitHistorySync::RegisterTransformFunc() int CommitHistorySync::Initialize(MultiVerKvDBSyncInterface *storagePtr, ICommunicator *communicateHandle) { if ((storagePtr == nullptr) || (communicateHandle == nullptr)) { - LOGE("CommitHistorySync::Initialize storagePtr or communicateHandle is nullptr"); return -E_INVALID_ARGS; } storagePtr_ = storagePtr; @@ -235,7 +227,6 @@ void CommitHistorySync::TimeOutCallback(MultiVerSyncTaskContext *context, const int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) { if (context == nullptr) { - LOGE("CommitHistorySync::SyncStart context is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); @@ -248,7 +239,6 @@ int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_GET_DEVICE_LATEST_COMMIT); } if ((errCode != E_OK) && (errCode != -E_NOT_FOUND)) { - LOGE("CommitHistorySync::SyncStart get device latest commit error=%d.", errCode); return errCode; } @@ -259,18 +249,16 @@ int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) int CommitHistorySync::RequestRecvCallback(const MultiVerSyncTaskContext *context, const Message *message) { if (!IsPacketValid(message, TYPE_REQUEST) || context == nullptr) { - LOGE("CommitHistorySync::RequestRecvCallback error in validity of package or context is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("CommitHistorySync::RequestRecvCallback packet is nullptr."); return -E_INVALID_ARGS; } std::vector commits; int errCode = RunPermissionCheck(context->GetDeviceId()); if (errCode == -E_NOT_PERMIT) { - LOGE("CommitHistorySync::RequestRecvCallback RunPermissionCheck not pass error=%d", errCode); + LOGE("CommitHistorySync::RequestRecvCallback RunPermissionCheck not pass"); SendAckPacket(context, commits, errCode, message); return errCode; } @@ -304,7 +292,6 @@ int CommitHistorySync::RequestRecvCallback(const MultiVerSyncTaskContext *contex int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const Message *message) { if (!IsPacketValid(message, TYPE_RESPONSE) || (context == nullptr)) { - LOGE("CommitHistorySync::AckRecvCallback error in validity of package or context is nullptr."); return -E_INVALID_ARGS; } @@ -313,7 +300,6 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M const CommitHistorySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("CommitHistorySync::AckRecvCallback packet is nullptr."); return -E_INVALID_ARGS; } packet->GetErrorCode(errCode); @@ -334,17 +320,14 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M int CommitHistorySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (inMsg == nullptr) { - LOGE("CommitHistorySync::RequestPacketCalculateLen inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { - LOGE("CommitHistorySync::RequestPacketCalculateLen packet is nullptr."); return -E_INVALID_ARGS; } if ((inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE) || (inMsg->GetMessageType() != TYPE_REQUEST)) { - LOGE("CommitHistorySync::RequestPacketCalculateLen get message error."); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -354,12 +337,10 @@ int CommitHistorySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { - LOGE("CommitHistorySync::RequestPacketSerialization buffer or inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { - LOGE("CommitHistorySync::RequestPacketSerialization packet is nullptr or packet length error."); return -E_INVALID_ARGS; } @@ -369,31 +350,25 @@ int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t leng int errCode = parcel.WriteUInt64(commitMap.size()); if (errCode != E_OK) { - LOGE("CommitHistorySync::RequestPacketSerialization parcel write size error=%d.", errCode); return -E_SECUREC_ERROR; } // commitMap Serialization for (auto &iter : commitMap) { errCode = parcel.WriteString(iter.first); if (errCode != E_OK) { - LOGE("CommitHistorySync::RequestPacketSerialization parcel write item error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteMultiVerCommit(iter.second); if (errCode != E_OK) { - LOGE("CommitHistorySync::RequestPacketSerialization parcel write" - " multivercommit error:%d.", errCode); return -E_SECUREC_ERROR; } } errCode = parcel.WriteUInt32(packet->GetVersion()); if (errCode != E_OK) { - LOGE("CommitHistorySync::RequestPacketSerialization parcel write version error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteVector(packet->GetReserved()); if (errCode != E_OK) { - LOGE("CommitHistorySync::RequestPacketSerialization parcel get reserved error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -403,7 +378,6 @@ int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t leng int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { - LOGE("CommitHistorySync::RequestPacketDeSerialization buffer or inMsg is nullptr"); return -E_INVALID_ARGS; } @@ -425,7 +399,6 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 commitMap[key] = val; len--; if (parcel.IsError()) { - LOGE("CommitHistorySync::RequestPacketDeSerialization parcel error."); return -E_INVALID_ARGS; } } @@ -449,7 +422,6 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 packet->SetReserved(reserved); int errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { - LOGE("CommitHistorySync::RequestPacketDeSerialization packet set external object error=%d", errCode); delete packet; packet = nullptr; } @@ -459,17 +431,14 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 int CommitHistorySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (inMsg == nullptr) { - LOGE("CommitHistorySync::AckPacketCalculateLen inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { - LOGE("CommitHistorySync::AckPacketCalculateLen packet is nullptr."); return -E_INVALID_ARGS; } if ((inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE) || (inMsg->GetMessageType() != TYPE_RESPONSE)) { - LOGE("CommitHistorySync::AckPacketCalculateLen get message error."); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -479,12 +448,10 @@ int CommitHistorySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { - LOGE("CommitHistorySync::AckPacketSerialization buffer or inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { - LOGE("CommitHistorySync::AckPacketSerialization packet is nullptr or lengeh error."); return -E_INVALID_ARGS; } @@ -497,12 +464,10 @@ int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, // errCode Serialization int errCode = parcel.WriteInt(ackErrCode); if (errCode != E_OK) { - LOGE("CommitHistorySync::AckPacketSerialization parcel write ErrCode error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteUInt32(packet->GetVersion()); if (errCode != E_OK) { - LOGE("CommitHistorySync::AckPacketSerialization parcel write version error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -510,12 +475,10 @@ int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, // commits vector Serialization errCode = parcel.WriteMultiVerCommits(commits); if (errCode != E_OK) { - LOGE("CommitHistorySync::AckPacketSerialization parcel write MultiVerCommits error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteVector(packet->GetReserved()); if (errCode != E_OK) { - LOGE("CommitHistorySync::AckPacketSerialization parcel get reserved error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -556,7 +519,6 @@ int CommitHistorySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t packet->SetReserved(reserved); int errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { - LOGE("CommitHistorySync::AckPacketDeSerialization set external object error=%d.", errCode); delete packet; packet = nullptr; } @@ -569,7 +531,6 @@ bool CommitHistorySync::IsPacketValid(const Message *inMsg, uint16_t messageType return false; } if (messageType != inMsg->GetMessageType()) { - LOGE("CommitHistorySync::IsPacketValid messageType error."); return false; } return true; @@ -577,7 +538,7 @@ bool CommitHistorySync::IsPacketValid(const Message *inMsg, uint16_t messageType int CommitHistorySync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT}; + SendConfig conf = {false, false, SEND_TIME_OUT, {}}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("CommitHistorySync::Send ERR! err = %d", errCode); @@ -590,7 +551,6 @@ int CommitHistorySync::GetDeviceLatestCommit(std::map readCommitMap; int errCode = storagePtr_->GetDeviceLatestCommit(readCommitMap); if (errCode != E_OK) { - LOGE("CommitHistorySync::GetDeviceLatestCommit get device latest commit ERR! err = %d", errCode); return errCode; } @@ -604,7 +564,6 @@ int CommitHistorySync::GetDeviceLatestCommit(std::mapTransferSyncCommitDevInfo(item.second, localDevice, false); if (errCode != E_OK) { - LOGE("CommitHistorySync::GetDeviceLatestCommit transfer synccommit devInfo ERR! err = %d", errCode); break; } commitMap.insert(std::make_pair(item.second.deviceInfo, item.second)); @@ -620,7 +579,7 @@ int CommitHistorySync::GetCommitTree(const std::mapTransferSyncCommitDevInfo(commitNode, localDevice, true); if (errCode != E_OK) { - LOGE("CommitHistorySync::GetCommitTree commitNode TransferSyncCommitDevInfo error = %d", errCode); return errCode; } newCommitMap.insert(std::make_pair(commitNode.deviceInfo, commitNode)); @@ -637,13 +595,11 @@ int CommitHistorySync::GetCommitTree(const std::mapGetCommitTree(newCommitMap, commits); if (errCode != E_OK) { - LOGE("CommitHistorySync::GetCommitTree GetCommitTree error = %d", errCode); return errCode; } for (auto &commit : commits) { errCode = storagePtr_->TransferSyncCommitDevInfo(commit, localDevice, false); if (errCode != E_OK) { - LOGE("CommitHistorySync::GetCommitTree commit TransferSyncCommitDevInfo error = %d", errCode); break; } } @@ -675,7 +631,7 @@ int CommitHistorySync::SendRequestPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete message; message = nullptr; - LOGE("CommitHistorySync::SendRequestPacket : SetExternalObject failed errCode=%d", errCode); + LOGE("CommitHistorySync::SendRequestPacket : SetExternalObject failed errCode:%d", errCode); return errCode; } message->SetSessionId(context->GetRequestSessionId()); @@ -687,7 +643,7 @@ int CommitHistorySync::SendRequestPacket(const MultiVerSyncTaskContext *context, } errCode = Send(message->GetTarget(), message); if (errCode != E_OK) { - LOGE("CommitHistorySync::SendRequestPacket : Send failed errCode=%d", errCode); + LOGE("CommitHistorySync::SendRequestPacket : Send failed errCode:%d", errCode); delete message; message = nullptr; } @@ -725,14 +681,14 @@ int CommitHistorySync::SendAckPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete ackMessage; ackMessage = nullptr; - LOGE("CommitHistorySync::SendAckPacket : SetExternalObject failed errCode=%d", errCode); + LOGE("CommitHistorySync::SendAckPacket : SetExternalObject failed errCode:%d", errCode); return errCode; } ackMessage->SetSequenceId(message->GetSequenceId()); ackMessage->SetSessionId(message->GetSessionId()); errCode = Send(ackMessage->GetTarget(), ackMessage); if (errCode != E_OK) { - LOGE("CommitHistorySync::SendAckPacket : Send failed errCode=%d", errCode); + LOGE("CommitHistorySync::SendAckPacket : Send failed errCode:%d", errCode); delete ackMessage; ackMessage = nullptr; } @@ -752,7 +708,7 @@ int CommitHistorySync::RunPermissionCheck(const std::string &deviceId) const uint8_t flag = CHECK_FLAG_SEND; int errCode = RuntimeContext::GetInstance()->RunPermissionCheck(userId, appId, storeId, deviceId, flag); if (errCode != E_OK) { - LOGE("[CommitHistorySync] RunPermissionCheck not pass errCode=%d, flag=%d", errCode, flag); + LOGE("[CommitHistorySync] RunPermissionCheck not pass errCode:%d, flag:%d", errCode, flag); return -E_NOT_PERMIT; } return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp index 55f12a119..3eef85f24 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp @@ -101,7 +101,6 @@ void CommunicatorProxy::Activate() uint32_t CommunicatorProxy::GetCommunicatorMtuSize() const { if (mainComm_ == nullptr) { - LOGD("[GetCommunicatorMtuSize] mainComm_ is nullptr"); return DBConstant::MIN_MTU_SIZE; } return mainComm_->GetCommunicatorMtuSize(); @@ -133,7 +132,6 @@ uint32_t CommunicatorProxy::GetCommunicatorMtuSize(const std::string &target) co uint32_t CommunicatorProxy::GetTimeout() const { if (mainComm_ == nullptr) { - LOGD("[GetTimeout] mainComm_ is nullptr"); return DBConstant::MIN_TIMEOUT; } return mainComm_->GetTimeout(); @@ -183,7 +181,6 @@ int CommunicatorProxy::GetRemoteCommunicatorVersion(const std::string &target, u } } if (targetCommunicator != nullptr) { - LOGD("[GetRemoteCommunicatorVersion] use equal label to get data"); int errCode = targetCommunicator->GetRemoteCommunicatorVersion(target, outVersion); RefObject::DecObjRef(targetCommunicator); return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp index 74a67fb72..e8885f87a 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp @@ -58,7 +58,6 @@ int DeviceManager::Initialize(ICommunicator *communicator, const std::function &offlineCallback) { if (communicator == nullptr) { - LOGE("[Initialize] communicator is nullptr"); return -E_INVALID_ARGS; } RefObject::IncObjRef(communicator); @@ -116,7 +115,7 @@ int DeviceManager::SendBroadCast(uint32_t msgId) if (msgId == LOCAL_DATA_CHANGED) { return SendLocalDataChanged(); } - LOGE("[DeviceManager] invalid BroadCast msgId=%u", msgId); + LOGE("[DeviceManager] invalid BroadCast msgId:%u", msgId); return -E_INVALID_ARGS; } @@ -139,10 +138,10 @@ int DeviceManager::SendLocalDataChanged() } msg->SetMessageId(LOCAL_DATA_CHANGED); msg->SetTarget(deviceId); - SendConfig conf = {false, false, SEND_TIME_OUT}; + SendConfig conf = {false, false, SEND_TIME_OUT, {}}; int errCode = communicator_->SendMessage(deviceId, msg, conf); if (errCode != E_OK) { - LOGE("[DeviceManager] SendLocalDataChanged to dev=%s{private} failed. err=%d", + LOGE("[DeviceManager] SendLocalDataChanged to dev %s{private} failed. err %d", deviceId.c_str(), errCode); delete msg; msg = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp index e691bdb0c..b91f2549f 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp @@ -104,7 +104,6 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) } int errCode = CheckSyncActive(syncInterface, isNeedActive); if (errCode != E_OK) { - LOGE("[Syncer] check sync active failed err=%d", errCode); return errCode; } @@ -121,7 +120,6 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) errCode = InitSyncEngine(syncInterface); if (errCode != E_OK) { - LOGE("[Syncer] init sync engine failed err=%d", errCode); return errCode; } syncEngine_->SetEqualIdentifier(); @@ -189,19 +187,17 @@ int GenericSyncer::Sync(const SyncParma ¶m) { int errCode = SyncParamCheck(param); if (errCode != E_OK) { - LOGE("[Syncer] SyncParamCheck failed err=%d", errCode); return errCode; } errCode = AddQueuedManualSyncSize(param.mode, param.wait); if (errCode != E_OK) { - LOGE("[Syncer] AddQueuedManualSyncSize failed err=%d", errCode); return errCode; } uint32_t syncId = GenerateSyncId(); errCode = PrepareSync(param, syncId); if (errCode != E_OK) { - LOGE("[Syncer] PrepareSync failed when sync called, err=%d", errCode); + LOGE("[Syncer] PrepareSync failed when sync called, err %d", errCode); return errCode; } PerformanceAnalysis::GetInstance()->StepTimeRecordEnd(PT_TEST_RECORDS::RECORD_SYNC_TOTAL); @@ -213,7 +209,6 @@ int GenericSyncer::PrepareSync(const SyncParma ¶m, uint32_t syncId) auto *operation = new (std::nothrow) SyncOperation(syncId, param.devices, param.mode, param.onComplete, param.wait); if (operation == nullptr) { - LOGE("[Syncer] operation is nullptr"); SubQueuedSyncSize(); return -E_OUT_OF_MEMORY; } @@ -247,7 +242,7 @@ int GenericSyncer::RemoveSyncOperation(int syncId) std::unique_lock lock(operationMapLock_); auto iter = syncOperationMap_.find(syncId); if (iter != syncOperationMap_.end()) { - LOGD("[Syncer] RemoveSyncOperation id=%d.", syncId); + LOGD("[Syncer] RemoveSyncOperation id:%d.", syncId); operation = iter->second; syncOperationMap_.erase(syncId); lock.unlock(); @@ -280,7 +275,6 @@ int GenericSyncer::StopSync() uint64_t GenericSyncer::GetTimeStamp() { if (timeHelper_ == nullptr) { - LOGD("[Syncer] timeHelper_ is nullptr."); return TimeHelper::GetSysCurrentTime(); } return timeHelper_->GetTime(); @@ -294,7 +288,6 @@ void GenericSyncer::QueryAutoSync(const InternalSyncParma ¶m) void GenericSyncer::AddSyncOperation(SyncOperation *operation) { if (operation == nullptr) { - LOGD("[Syncer] operation is nullptr."); return; } @@ -333,7 +326,7 @@ int GenericSyncer::InitMetaData(ISyncInterface *syncInterface) metadata_ = std::make_shared(); int errCode = metadata_->Initialize(syncInterface); if (errCode != E_OK) { - LOGE("[Syncer] metadata Initializeate failed! err=%d.", errCode); + LOGE("[Syncer] metadata Initializeate failed! err %d.", errCode); metadata_ = nullptr; } return errCode; @@ -348,7 +341,7 @@ int GenericSyncer::InitTimeHelper(ISyncInterface *syncInterface) timeHelper_ = std::make_shared(); int errCode = timeHelper_->Initialize(syncInterface, metadata_); if (errCode != E_OK) { - LOGE("[Syncer] TimeHelper init failed! err=%d.", errCode); + LOGE("[Syncer] TimeHelper init failed! err:%d.", errCode); timeHelper_ = nullptr; } return errCode; @@ -362,7 +355,6 @@ int GenericSyncer::InitSyncEngine(ISyncInterface *syncInterface) } int errCode = BuildSyncEngine(); if (errCode != E_OK) { - LOGE("[Syncer] BuildSyncEngine failed! err=%d.", errCode); return errCode; } const std::function onlineFunc = std::bind(&GenericSyncer::RemoteDataChanged, @@ -378,7 +370,7 @@ int GenericSyncer::InitSyncEngine(ISyncInterface *syncInterface) label_ = syncEngine_->GetLabel(); return E_OK; } else { - LOGE("[Syncer] SyncEngine init failed! err=%d.", errCode); + LOGE("[Syncer] SyncEngine init failed! err:%d.", errCode); if (syncEngine_ != nullptr) { RefObject::KillAndDecObjRef(syncEngine_); syncEngine_ = nullptr; @@ -397,7 +389,6 @@ int GenericSyncer::CheckSyncActive(ISyncInterface *syncInterface, bool isNeedAct LOGI("[Syncer] syncer no need to active"); int errCode = BuildSyncEngine(); if (errCode != E_OK) { - LOGE("[Syncer] BuildSyncEngine failed! err=%d.", errCode); return errCode; } return -E_NO_NEED_ACTIVE; @@ -497,7 +488,6 @@ int GenericSyncer::SyncModuleInit() if (!isInit) { int errCode = SyncResourceInit(); if (errCode != E_OK) { - LOGE("[Syncer] SyncResourceInit failed! err=%d.", errCode); return errCode; } isInit = true; @@ -551,36 +541,33 @@ int GenericSyncer::SyncResourceInit() int GenericSyncer::GetQueuedSyncSize(int *queuedSyncSize) const { if (queuedSyncSize == nullptr) { - LOGE("[GenericSyncer] queuedSyncSize is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); *queuedSyncSize = queuedManualSyncSize_; - LOGI("[GenericSyncer] GetQueuedSyncSize=%d", queuedManualSyncSize_); + LOGI("[GenericSyncer] GetQueuedSyncSize:%d", queuedManualSyncSize_); return E_OK; } int GenericSyncer::SetQueuedSyncLimit(const int *queuedSyncLimit) { if (queuedSyncLimit == nullptr) { - LOGE("[GenericSyncer] queuedSyncLimit is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); queuedManualSyncLimit_ = *queuedSyncLimit; - LOGI("[GenericSyncer] SetQueuedSyncLimit=%d", queuedManualSyncLimit_); + LOGI("[GenericSyncer] SetQueuedSyncLimit:%d", queuedManualSyncLimit_); return E_OK; } int GenericSyncer::GetQueuedSyncLimit(int *queuedSyncLimit) const { if (queuedSyncLimit == nullptr) { - LOGE("[GenericSyncer] queuedSyncLimit is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); *queuedSyncLimit = queuedManualSyncLimit_; - LOGI("[GenericSyncer] GetQueuedSyncLimit=%d", queuedManualSyncLimit_); + LOGI("[GenericSyncer] GetQueuedSyncLimit:%d", queuedManualSyncLimit_); return E_OK; } @@ -611,15 +598,15 @@ bool GenericSyncer::IsQueuedManualSyncFull(int mode, bool wait) const { std::lock_guard lock(queuedManualSyncLock_); if (IsManualSync(mode) && (!manualSyncEnable_)) { - LOGI("[GenericSyncer] manualSyncEnable_=false"); + LOGI("[GenericSyncer] manualSyncEnable_:false"); return true; } if (IsManualSync(mode) && (!wait)) { if (queuedManualSyncSize_ < queuedManualSyncLimit_) { - LOGD("[GenericSyncer] queuedManualSyncSize_=%d < queuedManualSyncLimit_=%d", queuedManualSyncSize_, - queuedManualSyncLimit_); return false; } else { + LOGD("[GenericSyncer] queuedManualSyncSize_:%d < queuedManualSyncLimit_:%d", queuedManualSyncSize_, + queuedManualSyncLimit_); return true; } } else { @@ -641,7 +628,7 @@ int GenericSyncer::DisableManualSync(void) { std::lock_guard lock(queuedManualSyncLock_); if (queuedManualSyncSize_ > 0) { - LOGD("[GenericSyncer] DisableManualSync fail, queuedManualSyncSize_=%d", queuedManualSyncSize_); + LOGD("[GenericSyncer] DisableManualSync fail, queuedManualSyncSize_:%d", queuedManualSyncSize_); return -E_BUSY; } manualSyncEnable_ = false; @@ -662,7 +649,7 @@ int GenericSyncer::GetLocalIdentity(std::string &outTarget) const std::string deviceId; int errCode = RuntimeContext::GetInstance()->GetLocalIdentity(deviceId); if (errCode != E_OK) { - LOGE("[GenericSyncer] GetLocalIdentity fail errCode=%d", errCode); + LOGE("[GenericSyncer] GetLocalIdentity fail errCode:%d", errCode); return errCode; } outTarget = DBCommon::TransferHashString(deviceId); @@ -701,7 +688,6 @@ void GenericSyncer::GetOnlineDevices(std::vector &devices) const int GenericSyncer::SetSyncRetry(bool isRetry) { if (syncEngine_ == nullptr) { - LOGE("[Syncer] syncEngine_ is nullptr"); return -E_NOT_INIT; } syncEngine_->SetSyncRetry(isRetry); @@ -712,7 +698,6 @@ int GenericSyncer::SetEqualIdentifier(const std::string &identifier, const std:: { std::lock_guard lock(syncerLock_); if (syncEngine_ == nullptr) { - LOGE("[Syncer] syncEngine_ is nullptr"); return -E_NOT_INIT; } int errCode = syncEngine_->SetEqualIdentifier(identifier, targets); @@ -750,11 +735,9 @@ int GenericSyncer::SyncParamCheck(const SyncParma ¶m) const std::lock_guard lock(syncerLock_); int errCode = StatusCheck(); if (errCode != E_OK) { - LOGE("[Syncer] StatusCheck failed err=%d", errCode); return errCode; } if (!IsValidDevices(param.devices) || !IsValidMode(param.mode)) { - LOGE("[Syncer] Validity error"); return -E_INVALID_ARGS; } if (IsQueuedManualSyncFull(param.mode, param.wait)) { @@ -785,7 +768,6 @@ int GenericSyncer::BuildSyncEngine() } syncEngine_ = CreateSyncEngine(); if (syncEngine_ == nullptr) { - LOGE("[Syncer] syncEngine_ is nullptr"); return -E_OUT_OF_MEMORY; } syncEngine_->OnLastRef([this]() { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 7a9efb790..2ab367bb6 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -54,11 +54,9 @@ int Metadata::Initialize(ISyncInterface* storage) int errCode = GetMetadataFromDb(key, timeOffset); if (errCode == -E_NOT_FOUND) { - LOGD("[Metadata][Initialize] GetMetadataFromDb failed errCode=%d", errCode); - uint64_t randTimeOffset = GetRandTimeOffset(); - int err = SaveLocalTimeOffset(TimeHelper::BASE_OFFSET + static_cast(randTimeOffset)); + int err = SaveLocalTimeOffset(TimeHelper::BASE_OFFSET); if (err != E_OK) { - LOGD("[Metadata][Initialize]SaveLocalTimeOffset failed errCode=%d", err); + LOGD("[Metadata][Initialize]SaveLocalTimeOffset failed errCode:%d", err); return err; } } else if (errCode == E_OK) { @@ -82,7 +80,7 @@ int Metadata::SaveTimeOffset(const DeviceID &deviceId, TimeOffset inValue) GetMetaDataValue(deviceId, metadata, true); metadata.timeOffset = inValue; metadata.lastUpdateTime = TimeHelper::GetSysCurrentTime(); - LOGD("Metadata::SaveTimeOffset = %lld dev=%s", inValue, STR_MASK(deviceId)); + LOGD("Metadata::SaveTimeOffset = %lld dev %s", inValue, STR_MASK(deviceId)); return SaveMetaDataValue(deviceId, metadata); } @@ -142,7 +140,7 @@ int Metadata::SaveLocalTimeOffset(TimeOffset timeOffset) LOGD("Metadata::SaveLocalTimeOffset offset = %lld", timeOffset); int errCode = SetMetadataToDb(localTimeOffsetValue, timeOffsetValue); if (errCode != E_OK) { - LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode=%d", errCode); + LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode:%d", errCode); } return errCode; } @@ -169,15 +167,15 @@ int Metadata::EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, // peerWaterMark must be erased at last int errCode = SavePeerWaterMark(deviceId, 0, isNeedHash); if (errCode != E_OK) { - LOGE("[Metadata] erase peerWaterMark failed errCode=%d", errCode); + LOGE("[Metadata] erase peerWaterMark failed errCode:%d", errCode); return errCode; } if (errCodeQuerySync != E_OK) { - LOGE("[Metadata] erase queryWaterMark failed errCode=%d", errCodeQuerySync); + LOGE("[Metadata] erase queryWaterMark failed errCode:%d", errCodeQuerySync); return errCodeQuerySync; } if (errCodeDeleteSync != E_OK) { - LOGE("[Metadata] erase deleteWaterMark failed errCode=%d", errCodeDeleteSync); + LOGE("[Metadata] erase deleteWaterMark failed errCode:%d", errCodeDeleteSync); return errCodeDeleteSync; } return E_OK; @@ -202,7 +200,6 @@ int Metadata::SaveMetaDataValue(const DeviceID &deviceId, const MetaDataValue &i std::vector value; int errCode = SerializeMetaData(inValue, value); if (errCode != E_OK) { - LOGE("Metadata::SaveMetaDataValue SerializeMetaData failed errCode=%d", errCode); return errCode; } @@ -212,7 +209,7 @@ int Metadata::SaveMetaDataValue(const DeviceID &deviceId, const MetaDataValue &i DBCommon::StringToVector(hashDeviceId, key); errCode = SetMetadataToDb(key, value); if (errCode != E_OK) { - LOGE("Metadata::SetMetadataToDb failed errCode=%d", errCode); + LOGE("Metadata::SetMetadataToDb failed errCode:%d", errCode); return errCode; } PutMetadataToMap(hashDeviceId, inValue); @@ -252,7 +249,6 @@ int Metadata::DeSerializeMetaData(const std::vector &inValue, MetaDataV int Metadata::GetMetadataFromDb(const std::vector &key, std::vector &outValue) const { if (naturalStoragePtr_ == nullptr) { - LOGE("Metadata::GetMetadataFromDb naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->GetMetaData(key, outValue); @@ -261,7 +257,6 @@ int Metadata::GetMetadataFromDb(const std::vector &key, std::vector &key, const std::vector &inValue) { if (naturalStoragePtr_ == nullptr) { - LOGE("Metadata::SetMetadataToDb naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->PutMetaData(key, inValue); @@ -270,7 +265,6 @@ int Metadata::SetMetadataToDb(const std::vector &key, const std::vector int Metadata::DeleteMetaDataFromDB(const std::vector &keys) const { if (naturalStoragePtr_ == nullptr) { - LOGE("Metadata::DeleteMetaDataFromDB naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->DeleteMetaData(keys); @@ -297,7 +291,6 @@ int64_t Metadata::StringToLong(const std::vector &value) const int Metadata::GetAllMetadataKey(std::vector> &keys) { if (naturalStoragePtr_ == nullptr) { - LOGE("Metadata::GetAllMetadataKey naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->GetAllMetaKeys(keys); @@ -329,17 +322,15 @@ int Metadata::LoadAllMetadata() std::vector> querySyncIds; for (const auto &deviceId : metaDataKeys) { if (IsMetaDataKey(deviceId, DEVICEID_PREFIX_KEY)) { - int errCode = LoadDeviceIdDataToMap(deviceId); + errCode = LoadDeviceIdDataToMap(deviceId); if (errCode != E_OK) { - LOGE("[Metadata] LoadDeviceIdDataToMap failed err=%d", errCode); return errCode; } } else if (IsMetaDataKey(deviceId, QuerySyncWaterMarkHelper::GetQuerySyncPrefixKey())) { querySyncIds.push_back(deviceId); } else if (IsMetaDataKey(deviceId, QuerySyncWaterMarkHelper::GetDeleteSyncPrefixKey())) { - int errCode = querySyncWaterMarkHelper_.LoadDeleteSyncDataToCache(deviceId); + errCode = querySyncWaterMarkHelper_.LoadDeleteSyncDataToCache(deviceId); if (errCode != E_OK) { - LOGE("[Metadata] LoadDeleteSyncDataToCache failed err=%d", errCode); return errCode; } } @@ -352,14 +343,12 @@ int Metadata::LoadDeviceIdDataToMap(const Key &key) std::vector value; int errCode = GetMetadataFromDb(key, value); if (errCode != E_OK) { - LOGE("Metadata::LoadDeviceIdDataToMap GetMetadataFromDb failed err=%d", errCode); return errCode; } MetaDataValue metaValue; std::string metaKey(key.begin(), key.end()); errCode = DeSerializeMetaData(value, metaValue); if (errCode != E_OK) { - LOGE("Metadata::LoadDeviceIdDataToMap DeSerializeMetaData failed err=%d", errCode); return errCode; } std::lock_guard lockGuard(metadataLock_); @@ -400,7 +389,6 @@ int Metadata::GetRecvQueryWaterMark(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { - LOGE("Metadata::GetRecvQueryWaterMark GetQueryWaterMark failed err=%d", errCode); return errCode; } WaterMark peerWaterMark; @@ -421,7 +409,6 @@ int Metadata::GetSendQueryWaterMark(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { - LOGE("Metadata::GetSendQueryWaterMark GetQueryWaterMark failed err=%d", errCode); return errCode; } if (isAutoLift) { @@ -445,7 +432,6 @@ int Metadata::GetLastQueryTime(const std::string &queryIdentify, const std::stri QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { - LOGE("Metadata::GetLastQueryTime GetQueryWaterMark failed err=%d", errCode); return errCode; } timeStamp = queryWaterMark.lastQueryTime; @@ -463,7 +449,6 @@ int Metadata::GetSendDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &wa DeleteWaterMark deleteWaterMark; int errCode = querySyncWaterMarkHelper_.GetDeleteSyncWaterMark(deviceId, deleteWaterMark); if (errCode != E_OK) { - LOGE("Metadata::GetSendDeleteSyncWaterMark GetDeleteSyncWaterMark failed err=%d", errCode); return errCode; } if (isAutoLift) { @@ -486,7 +471,6 @@ int Metadata::GetRecvDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &wa DeleteWaterMark deleteWaterMark; int errCode = querySyncWaterMarkHelper_.GetDeleteSyncWaterMark(deviceId, deleteWaterMark); if (errCode != E_OK) { - LOGE("Metadata::GetRecvDeleteSyncWaterMark GetDeleteSyncWaterMark failed err=%d", errCode); return errCode; } WaterMark peerWaterMark; @@ -554,7 +538,6 @@ int Metadata::ResetMetaDataAfterRemoveData(const DeviceID &deviceId) metadata.localWaterMark = 0; return SaveMetaDataValue(deviceId, metadata); } - LOGI("Metadata::ResetMetaDataAfterRemoveData hashDeviceId not found"); return -E_NOT_FOUND; } @@ -575,7 +558,6 @@ void Metadata::GetRemoveDataMark(const DeviceID &deviceId, uint64_t &outValue) int Metadata::DeleteMetaDataByPrefixKey(const Key &keyPrefix) const { if (naturalStoragePtr_ == nullptr) { - LOGD("Metadata::DeleteMetaDataByPrefixKey naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->DeleteMetaDataByPrefixKey(keyPrefix); @@ -590,7 +572,6 @@ uint64_t Metadata::GetQueryLastTimestamp(const DeviceID &deviceId, const std::st int errCode = GetMetadataFromDb(key, value); std::lock_guard lockGuard(metadataLock_); if (errCode == -E_NOT_FOUND) { - LOGI("errCode is -E_NOT_FOUND"); auto iter = queryIdMap_.find(deviceId); if (iter != queryIdMap_.end()) { if (iter->second.find(hashqueryId) == iter->second.end()) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp index 483df48d0..662c6bb3f 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp @@ -100,7 +100,6 @@ MultiVerDataSync::~MultiVerDataSync() int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { - LOGE("MultiVerDataSync::Serialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -110,7 +109,6 @@ int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Mess case TYPE_RESPONSE: return AckPacketSerialization(buffer, length, inMsg); default: - LOGE("MultiVerDataSync::Serialization message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -118,7 +116,6 @@ int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Mess int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { - LOGE("MultiVerDataSync::DeSerialization buffer is nullptr or packet validity error"); return -E_MESSAGE_ID_ERROR; } @@ -128,7 +125,6 @@ int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Me case TYPE_RESPONSE: return AckPacketDeSerialization(buffer, length, inMsg); default: - LOGE("MultiVerDataSync::DeSerialization message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -136,7 +132,6 @@ int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Me uint32_t MultiVerDataSync::CalculateLen(const Message *inMsg) { if (!(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { - LOGE("MultiVerDataSync::CalculateLen packet validity error"); return 0; } @@ -172,7 +167,6 @@ int MultiVerDataSync::RegisterTransformFunc() int MultiVerDataSync::Initialize(MultiVerKvDBSyncInterface *storagePtr, ICommunicator *communicateHandle) { if ((storagePtr == nullptr) || (communicateHandle == nullptr)) { - LOGE("MultiVerDataSync::Initialize storagePtr or communicateHandle is nullptr"); return -E_INVALID_ARGS; } storagePtr_ = storagePtr; @@ -188,7 +182,6 @@ void MultiVerDataSync::TimeOutCallback(MultiVerSyncTaskContext *context, const M int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) { if (context == nullptr) { - LOGE("MultiVerDataSync::SyncStart context is nullptr"); return -E_INVALID_ARGS; } LOGD("MultiVerDataSync::SyncStart dst=%s{private}, begin", context->GetDeviceId().c_str()); @@ -202,7 +195,6 @@ int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_DATA_GET_VALID_COMMIT); } if (errCode != E_OK) { - LOGI("MultiVerDataSync::SyncStart GetValidCommit failed"); // sync don't need start SendFinishedRequest(context); return errCode; @@ -216,22 +208,18 @@ int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) int MultiVerDataSync::RequestRecvCallback(const MultiVerSyncTaskContext *context, const Message *message) { if (message == nullptr || context == nullptr) { - LOGE("MultiVerDataSync::RequestRecvCallback message or context is nullptr"); return -E_INVALID_ARGS; } if (!IsPacketValid(message, TYPE_REQUEST)) { - LOGE("MultiVerDataSync::RequestRecvCallback packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("MultiVerDataSync::RequestRecvCallback packet is nullptr"); return -E_INVALID_ARGS; } if (packet->GetErrCode() == -E_LAST_SYNC_FRAME) { - LOGE("MultiVerDataSync::RequestRecvCallback packet errCode equal -E_LAST_SYNC_FRAME"); return -E_LAST_SYNC_FRAME; } MultiVerCommitNode commit; @@ -262,23 +250,19 @@ int MultiVerDataSync::RequestRecvCallback(const MultiVerSyncTaskContext *context int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Message *message) { if (message == nullptr) { - LOGE("MultiVerDataSync::AckRecvCallback message is nullptr"); return -E_INVALID_ARGS; } if (!IsPacketValid(message, TYPE_RESPONSE) || (context == nullptr)) { - LOGE("MultiVerDataSync::AckRecvCallback context is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = message->GetObject(); if (packet == nullptr) { - LOGE("MultiVerDataSync::AckRecvCallback packet is nullptr"); return -E_INVALID_ARGS; } int32_t errCode = E_OK; packet->GetErrorCode(errCode); if (errCode != E_OK) { - LOGE("MultiVerDataSync::AckRecvCallback packet GetErrorCode=%d", errCode); return errCode; } std::vector> dataEntries; @@ -302,7 +286,6 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me entry = entries[0]; errCode = entry->GetValueHash(valueHashes); if (errCode != E_OK) { - LOGE("MultiVerDataSync::AckRecvCallback entry GetValueHash errCode=%d", errCode); return errCode; } } @@ -333,12 +316,11 @@ void MultiVerDataSync::ReleaseKvEntry(const MultiVerKvEntry *entry) void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *context) { if (context == nullptr) { - LOGE("MultiVerDataSync::SendFinishedRequest context is nullptr"); return; } MultiVerRequestPacket *packet = new (std::nothrow) MultiVerRequestPacket(); if (packet == nullptr) { - LOGE("MultiVerRequestPacket::SendFinishedRequest : new packet error"); + LOGE("MultiVerRequestPacket::SendRequestPacket : new packet error"); return; } packet->SetErrCode(-E_LAST_SYNC_FRAME); @@ -346,7 +328,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex if (message == nullptr) { delete packet; packet = nullptr; - LOGE("MultiVerDataSync::SendFinishedRequest : new message error"); + LOGE("MultiVerDataSync::SendRequestPacket : new message error"); return; } message->SetMessageType(TYPE_REQUEST); @@ -357,7 +339,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex packet = nullptr; delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendFinishedRequest] : SetExternalObject failed errCode=%d", errCode); + LOGE("[MultiVerDataSync][SendFinishedRequest] : SetExternalObject failed errCode:%d", errCode); return; } message->SetSessionId(context->GetRequestSessionId()); @@ -367,7 +349,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex if (errCode != E_OK) { delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest failed, err=%d", errCode); + LOGE("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest failed, err %d", errCode); } LOGI("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest dst=%s{private}", context->GetDeviceId().c_str()); } @@ -375,12 +357,10 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex int MultiVerDataSync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { if ((inMsg == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { - LOGE("MultiVerDataSync::RequestPacketCalculateLen inMsg is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { - LOGE("MultiVerDataSync::RequestPacketCalculateLen packet is nullptr"); return -E_INVALID_ARGS; } @@ -391,12 +371,10 @@ int MultiVerDataSync::RequestPacketCalculateLen(const Message *inMsg, uint32_t & int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { - LOGE("MultiVerDataSync::RequestPacketSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { - LOGE("MultiVerDataSync::RequestPacketSerialization packet is nullptr"); return -E_INVALID_ARGS; } @@ -407,7 +385,6 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt Parcel parcel(buffer, length); int errCode = parcel.WriteInt(ackCode); if (errCode != E_OK) { - LOGE("MultiVerDataSync::RequestPacketSerialization parcel write ackCode error=%d", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -415,7 +392,6 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt // commitMap Serialization errCode = parcel.WriteMultiVerCommit(commit); if (errCode != E_OK) { - LOGE("MultiVerDataSync::RequestPacketSerialization parcel write commit error=%d", errCode); return -E_SECUREC_ERROR; } @@ -425,7 +401,6 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { - LOGE("MultiVerDataSync::RequestPacketDeSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -434,7 +409,6 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 int32_t pktErrCode; uint64_t packLen = parcel.ReadInt(pktErrCode); if (parcel.IsError()) { - LOGE("MultiVerDataSync::RequestPacketDeSerialization parcel error"); return -E_INVALID_ARGS; } parcel.EightByteAlign(); @@ -442,7 +416,6 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 // commit DeSerialization packLen += parcel.ReadMultiVerCommit(commit); if (packLen != length || parcel.IsError()) { - LOGE("MultiVerDataSync::RequestPacketDeSerialization parcel length=%llu error", packLen); return -E_INVALID_ARGS; } MultiVerRequestPacket *packet = new (std::nothrow) MultiVerRequestPacket(); @@ -463,13 +436,11 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 int MultiVerDataSync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (!IsPacketValid(inMsg, TYPE_RESPONSE)) { - LOGE("MultiVerDataSync::AckPacketCalculateLen packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { - LOGE("MultiVerDataSync::AckPacketCalculateLen packet is nullptr"); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -479,12 +450,10 @@ int MultiVerDataSync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_RESPONSE)) { - LOGE("MultiVerDataSync::AckPacketSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { - LOGE("MultiVerDataSync::AckPacketSerialization packet length=%llu error or packet is nullptr", length); return -E_INVALID_ARGS; } @@ -497,7 +466,6 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c // errCode Serialization errCode = parcel.WriteInt(errCode); if (errCode != E_OK) { - LOGE("MultiVerDataSync::AckPacketSerialization packet get errorCode=%d", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -506,7 +474,6 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c for (const auto &iter : entries) { errCode = parcel.WriteVectorChar(iter); if (errCode != E_OK) { - LOGE("MultiVerDataSync::AckPacketSerialization write entry errorCode=%d", errCode); return -E_SECUREC_ERROR; } } @@ -517,7 +484,6 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_RESPONSE)) { - LOGE("MultiVerDataSync::AckPacketDeSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -527,7 +493,6 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l // errCode DeSerialization uint32_t packLen = parcel.ReadInt(pktErrCode); if (parcel.IsError()) { - LOGE("MultiVerDataSync::AckPacketDeSerialization parcel read error"); return -E_INVALID_ARGS; } parcel.EightByteAlign(); @@ -541,7 +506,6 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l // A valid dataItem got, Save to storage entries.push_back(data); if (parcel.IsError()) { - LOGE("MultiVerDataSync::AckPacketDeSerialization parcel read entry error"); return -E_INVALID_ARGS; } } @@ -563,7 +527,6 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l bool MultiVerDataSync::IsPacketValid(const Message *inMsg, uint16_t messageType) { if ((inMsg == nullptr) || (inMsg->GetMessageId() != MULTI_VER_DATA_SYNC_MESSAGE)) { - LOGE("MultiVerDataSync::AckPacketDeSerialization inMsg is nullptr or get message error"); return false; } if (messageType != inMsg->GetMessageType()) { @@ -613,7 +576,7 @@ bool MultiVerDataSync::IsCommitExisted(const MultiVerCommitNode &commit) int MultiVerDataSync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT}; + SendConfig conf = {false, false, SEND_TIME_OUT, {}}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("MultiVerDataSync::Send ERR! ERR = %d", errCode); @@ -644,7 +607,7 @@ int MultiVerDataSync::SendRequestPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendRequestPacket] : SetExternalObject failed errCode=%d", errCode); + LOGE("[MultiVerDataSync][SendRequestPacket] : SetExternalObject failed errCode:%d", errCode); return errCode; } message->SetSessionId(context->GetRequestSessionId()); @@ -701,7 +664,7 @@ int MultiVerDataSync::SendAckPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete ackMessage; ackMessage = nullptr; - LOGE("[MultiVerDataSync][SendAckPacket] : SetExternalObject failed errCode=%d", errCode); + LOGE("[MultiVerDataSync][SendAckPacket] : SetExternalObject failed errCode:%d", errCode); return errCode; } ackMessage->SetSequenceId(message->GetSequenceId()); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index af46b4a6c..8e7fe90a5 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -62,12 +62,10 @@ int MultiVerSyncStateMachine::Initialize(ISyncTaskContext *context, ISyncInterfa std::shared_ptr &metadata, ICommunicator *communicator) { if (context == nullptr || syncInterface == nullptr || metadata == nullptr || communicator == nullptr) { - LOGE("MultiVerSyncStateMachine::Initialize args is nullptr"); return -E_INVALID_ARGS; } int errCode = SyncStateMachine::Initialize(context, syncInterface, metadata, communicator); if (errCode != E_OK) { - LOGE("MultiVerSyncStateMachine::Initialize Initialize error=%d", errCode); return errCode; } @@ -78,9 +76,10 @@ int MultiVerSyncStateMachine::Initialize(ISyncTaskContext *context, ISyncInterfa errCode = timeSync_->Initialize(communicator, metadata, syncInterface, context->GetDeviceId()); if (errCode != E_OK) { - LOGE("MultiVerSyncStateMachine::Initialize timeSync_->Initialize failed err=%d", errCode); + LOGE("timeSync_->Initialize failed err %d", errCode); goto ERROR_OUT; } + LOGD("timeSync_->Initialize OK"); // init functions below will never fail multiVerStorage_ = static_cast(syncInterface); @@ -105,7 +104,7 @@ void MultiVerSyncStateMachine::SyncStep() int errCode = RuntimeContext::GetInstance()->ScheduleTask( std::bind(&MultiVerSyncStateMachine::SyncStepInnerLocked, this)); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] Schedule SyncStep failed errCode=%d", errCode); + LOGE("[MultiVerSyncStateMachine] Schedule SyncStep failed"); RefObject::DecObjRef(communicator_); RefObject::DecObjRef(context_); } @@ -124,18 +123,16 @@ int MultiVerSyncStateMachine::MessageCallbackCheck(const Message *inMsg) { RefObject::AutoLock lock(context_); if (context_->IsKilled()) { - LOGE("MultiVerSyncStateMachine::MessageCallbackCheck context is killed"); return -E_OBJ_IS_KILLED; } if (!IsPacketValid(inMsg)) { - LOGE("MultiVerSyncStateMachine::MessageCallbackCheck packet validity error"); return -E_INVALID_ARGS; } if ((inMsg->GetMessageType() == TYPE_RESPONSE) && (inMsg->GetMessageId() != TIME_SYNC_MESSAGE)) { context_->IncSequenceId(); int errCode = ResetWatchDog(); if (errCode != E_OK) { - LOGW("[MultiVerSyncStateMachine][MessageCallback] ResetWatchDog failed , err=%d", errCode); + LOGW("[MultiVerSyncStateMachine][MessageCallback] ResetWatchDog failed , err %d", errCode); } } return E_OK; @@ -144,7 +141,6 @@ int MultiVerSyncStateMachine::MessageCallbackCheck(const Message *inMsg) int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) { if (inMsg == nullptr) { - LOGE("MultiVerSyncStateMachine::ReceiveMessageCallback inMsg is nullptr"); return -E_INVALID_ARGS; } if (inMsg->IsFeedbackError()) { @@ -152,13 +148,11 @@ int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) return -static_cast(inMsg->GetErrorNo()); } if (inMsg->GetMessageId() == TIME_SYNC_MESSAGE) { - LOGD("MultiVerSyncStateMachine::ReceiveMessageCallback messageid is time sync"); return TimeSyncPacketRecvCallback(context_, inMsg); } std::lock_guard lock(stateMachineLock_); int errCode = MessageCallbackCheck(inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] MessageCallbackCheck error=%d", errCode); return errCode; } switch (inMsg->GetMessageId()) { @@ -179,7 +173,6 @@ int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) break; } if (errCode == -E_LAST_SYNC_FRAME) { - LOGE("[MultiVerSyncStateMachine] errCode is -E_LAST_SYNC_FRAME"); SyncResponseEnd(inMsg->GetSessionId()); return errCode; } @@ -206,7 +199,7 @@ int MultiVerSyncStateMachine::CommitHistorySyncStepInner(void) { int errCode = commitHistorySync_->SyncStart(context_); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][CommitHistorySyncStep] failed, errCode=%d", errCode); + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncStep] failed, errCode %d", errCode); } return errCode; } @@ -250,8 +243,6 @@ void MultiVerSyncStateMachine::SyncStepInnerLocked() if (errCode == -E_NOT_FOUND) { int err = OneCommitSyncFinish(); if (err != E_OK) { - LOGD("[MultiVerSyncStateMachine][SyncStepInnerLocked] OneCommitSyncFinish failed" - ", error=%d", err); valueSliceSync_->SendFinishedRequest(context_); Abort(); goto SYNC_STEP_SAFE_OUT; @@ -288,7 +279,7 @@ int MultiVerSyncStateMachine::StartSyncInner() } int errCode = StartWatchDog(); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][StartSync] WatchDog start failed! err=%d", errCode); + LOGE("[MultiVerSyncStateMachine][StartSync] WatchDog start failed! err:%d", errCode); return errCode; } SyncStep(); @@ -327,7 +318,6 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC { int errCode; if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != TIME_SYNC_MESSAGE)) { - LOGE("[MultiVerSyncStateMachine][TimeSyncPacketRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } switch (inMsg->GetMessageType()) { @@ -337,7 +327,7 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC case TYPE_RESPONSE: errCode = timeSync_->AckRecv(inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] TimeSyncPacketRecvCallback AckRecv failed err=%d", errCode); + LOGE("[MultiVerSyncStateMachine] TimeSyncPacketRecvCallback AckRecv failed err %d", errCode); } return errCode; default: @@ -348,12 +338,10 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE)) { - LOGE("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; - LOGD("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: if (performance != nullptr) { @@ -366,7 +354,6 @@ int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskC } errCode = commitHistorySync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] AckRecvCallback error=%d", errCode); return errCode; } currentState_ = MULTI_VER_DATA_ENTRY_SYNC; @@ -380,12 +367,10 @@ int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskC int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != MULTI_VER_DATA_SYNC_MESSAGE)) { - LOGE("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; - LOGD("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: return multiVerDataSync_->RequestRecvCallback(context, inMsg); @@ -395,7 +380,6 @@ int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContex } errCode = multiVerDataSync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] AckRecvCallback error=%d", errCode); multiVerDataSync_->SendFinishedRequest(context); return errCode; } @@ -410,12 +394,10 @@ int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContex int MultiVerSyncStateMachine::ValueSlicePktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != VALUE_SLICE_SYNC_MESSAGE)) { - LOGE("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; - LOGD("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: return valueSliceSync_->RequestRecvCallback(context, inMsg); @@ -425,7 +407,6 @@ int MultiVerSyncStateMachine::ValueSlicePktRecvCallback(MultiVerSyncTaskContext } errCode = valueSliceSync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] AckRecvCallback error=%d", errCode); valueSliceSync_->SendFinishedRequest(context); return errCode; } @@ -451,7 +432,7 @@ void MultiVerSyncStateMachine::Finish() performance->StepTimeRecordStart(MV_TEST_RECORDS::RECORD_MERGE); } int errCode = multiVerDataSync_->MergeSyncCommit(commit, commits); - LOGD("MultiVerSyncStateMachine::Finish merge src=%s, MergeSyncCommit errCode=%d", + LOGD("MultiVerSyncStateMachine::Finish merge src=%s, MergeSyncCommit errCode:%d", STR_MASK(context_->GetDeviceId()), errCode); if (performance != nullptr) { performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_MERGE); @@ -482,7 +463,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() STR_MASK(context_->GetDeviceId()), entries.size()); errCode = timeSync_->GetTimeOffset(outOffset, TIME_SYNC_WAIT_TIME); if (errCode != E_OK) { - LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset failed errCode=%d", errCode); + LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset fail errCode:%d", errCode); return errCode; } TimeStamp currentLocalTime = context_->GetCurrentLocalTime(); @@ -516,7 +497,6 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() bool MultiVerSyncStateMachine::IsPacketValid(const Message *inMsg) const { if (inMsg == nullptr) { - LOGE("[MultiVerSyncStateMachine][IsPacketValid] inMsg is nullptr"); return false; } @@ -571,12 +551,12 @@ void MultiVerSyncStateMachine::SyncResponseBegin(uint32_t sessionId) [this]() { int ret = RuntimeContext::GetInstance()->ScheduleTask([this](){ RefObject::DecObjRef(context_); }); if (ret != E_OK) { - LOGE("[MultiVerSyncStateMachine][SyncResponseEnd] timer finalizer ScheduleTask, errCode=%d", ret); + LOGE("[MultiVerSyncStateMachine][SyncResponseEnd] timer finalizer ScheduleTask, errCode %d", ret); } }, timerId); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][ResponseSessionBegin] SetTimer failed err=%d", errCode); + LOGE("[MultiVerSyncStateMachine][ResponseSessionBegin] SetTimer failed err %d", errCode); RefObject::DecObjRef(context_); return; } @@ -595,7 +575,7 @@ void MultiVerSyncStateMachine::SyncResponseEnd(uint32_t sessionId) return info.sessionId == sessionId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseEnd] Can't find sync response=%d", sessionId); + LOGW("[MultiVerSyncStateMachine][SyncResponseEnd] Can't find sync response %d", sessionId); return; } RuntimeContext::GetInstance()->RemoveTimer(iter->timerId); @@ -614,7 +594,7 @@ int MultiVerSyncStateMachine::SyncResponseTimeout(TimerId timerId) return info.timerId == timerId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId=%d", timerId); + LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %d", timerId); return E_OK; } sessionId = iter->sessionId; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp index 2a5ed2ce1..96599edac 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp @@ -30,7 +30,6 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf std::shared_ptr &metadata, ICommunicator *communicator) { if (deviceId.empty() || (syncInterface == nullptr) || (communicator == nullptr)) { - LOGE("[MultiVerSyncTaskContext][Initialize] args is nullptr."); return -E_INVALID_ARGS; } syncInterface_ = syncInterface; @@ -41,13 +40,12 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf timeHelper_ = std::make_unique(); int errCode = timeHelper_->Initialize(syncInterface, metadata); if (errCode != E_OK) { - LOGE("[MultiVerSyncTaskContext][Initialize] timeHelper Initialize failed, err=%d.", errCode); + LOGE("[MultiVerSyncTaskContext] timeHelper Initialize failed, err %d.", errCode); return errCode; } stateMachine_ = new (std::nothrow) MultiVerSyncStateMachine; if (stateMachine_ == nullptr) { - LOGE("[MultiVerSyncTaskContext][Initialize] stateMachine_ is nullptr."); return -E_OUT_OF_MEMORY; } @@ -67,7 +65,6 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf int MultiVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) { if (operation == nullptr) { - LOGE("[MultiVerSyncTaskContext][AddSyncOperation] operation is nullptr"); return -E_INVALID_ARGS; } @@ -79,7 +76,6 @@ int MultiVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) MultiVerSyncTarget *target = new (std::nothrow) MultiVerSyncTarget; if (target == nullptr) { - LOGE("[MultiVerSyncTaskContext][AddSyncOperation] target is nullptr"); return -E_OUT_OF_MEMORY; } target->SetSyncOperation(operation); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp index 1167508c0..65ac108a1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp @@ -36,7 +36,7 @@ MultiVerSyncer::~MultiVerSyncer() void MultiVerSyncer::EnableAutoSync(bool enable) { - LOGD("[Syncer] EnableAutoSync enable = %d, autoSyncEnable_ = %d", enable, autoSyncEnable_); + LOGD("[Syncer] EnableAutoSync enable = %d", enable); if (autoSyncEnable_ == enable) { return; } @@ -49,13 +49,12 @@ void MultiVerSyncer::EnableAutoSync(bool enable) std::vector devices; GetOnlineDevices(devices); if (devices.empty()) { - LOGD("[Syncer] devices is empty"); return; } int errCode = Sync(devices, SyncModeType::AUTO_PULL, nullptr, nullptr, false); if (errCode != E_OK) { - LOGE("[Syncer] sync start by EnableAutoSync failed err=%d", errCode); + LOGE("[Syncer] sync start by EnableAutoSync failed err %d", errCode); } } @@ -86,13 +85,13 @@ void MultiVerSyncer::LocalDataChanged(int notifyEvent) void MultiVerSyncer::RemoteDataChanged(const std::string &device) { - LOGD("[MultiVerSyncer] Remote data changed or device online dev=%s{private}", device.c_str()); + LOGD("[MultiVerSyncer] Remote data changed or device online dev %s{private}", device.c_str()); if (autoSyncEnable_) { std::vector devices; devices.push_back(device); int errCode = Sync(devices, SyncModeType::AUTO_PULL, nullptr, nullptr, false); if (errCode != E_OK) { - LOGE("[MultiVerSyncer] sync start by RemoteDataChanged failed err=%d", errCode); + LOGE("[MultiVerSyncer] sync start by RemoteDataChanged failed err %d", errCode); } } } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp index 19305a518..3a6a5cc65 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp @@ -58,7 +58,6 @@ int LruMap::Get(const std::string &key, QueryWaterMark &outValue) { std::lock_guard autoLock(lruLock_); if (cache_.count(key) == 0) { - LOGE("[Meta]Get count key is zero"); return -E_NOT_FOUND; } outValue = cache_[key]; @@ -104,7 +103,6 @@ int LruMap::Elimination(const std::string &key, const QueryWaterMark &inQueryWat int QuerySyncWaterMarkHelper::GetMetadataFromDb(const std::vector &key, std::vector &outValue) { if (storage_ == nullptr) { - LOGE("[Meta]GetMetadataFromDb storage_ is nullptr"); return -E_INVALID_DB; } return storage_->GetMetaData(key, outValue); @@ -113,7 +111,6 @@ int QuerySyncWaterMarkHelper::GetMetadataFromDb(const std::vector &key, int QuerySyncWaterMarkHelper::SetMetadataToDb(const std::vector &key, const std::vector &inValue) { if (storage_ == nullptr) { - LOGE("[Meta]SetMetadataToDb storage_ is nullptr"); return -E_INVALID_DB; } return storage_->PutMetaData(key, inValue); @@ -122,7 +119,6 @@ int QuerySyncWaterMarkHelper::SetMetadataToDb(const std::vector &key, c int QuerySyncWaterMarkHelper::DeleteMetaDataFromDB(const std::vector &keys) const { if (storage_ == nullptr) { - LOGE("[Meta]DeleteMetaDataFromDB storage_ is nullptr"); return -E_INVALID_DB; } return storage_->DeleteMetaData(keys); @@ -139,14 +135,12 @@ int QuerySyncWaterMarkHelper::LoadDeleteSyncDataToCache(const Key &deleteWaterMa std::vector value; int errCode = GetMetadataFromDb(deleteWaterMarkKey, value); if (errCode != E_OK) { - LOGE("[Meta]LoadDeleteSyncDataToCache GetMetadataFromDb error, errCode=%d", errCode); return errCode; } DeleteWaterMark deleteWaterMark; std::string dbKey(deleteWaterMarkKey.begin(), deleteWaterMarkKey.end()); errCode = DeSerializeDeleteWaterMark(value, deleteWaterMark); if (errCode != E_OK) { - LOGE("[Meta]LoadDeleteSyncDataToCache DeSerializeDeleteWaterMark error, errCode=%d", errCode); return errCode; } std::lock_guard autoLock(deleteSyncLock_); @@ -159,7 +153,6 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkInCacheAndDb(const std::string &c { // first get from cache_ int errCode = querySyncCache_.Get(cacheKey, queryWaterMark); - LOGD("[Meta]GetQueryWaterMark get code=%d", errCode); bool addToCache = false; if (errCode == -E_NOT_FOUND) { // second get from db @@ -172,6 +165,7 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkInCacheAndDb(const std::string &c } // something error return if (errCode != E_OK) { + LOGE("[Meta]GetQueryWaterMark Fail code = %d", errCode); return errCode; } // remember add to cache_ @@ -208,7 +202,6 @@ int QuerySyncWaterMarkHelper::SetLastQueryTime(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = GetQueryWaterMarkInCacheAndDb(cacheKey, queryWaterMark); if (errCode != E_OK) { - LOGE("[Meta]SetLastQueryTime GetQueryWaterMark error, errCode=%d", errCode); return errCode; } queryWaterMark.lastQueryTime = timeStamp; @@ -221,7 +214,6 @@ int QuerySyncWaterMarkHelper::SetRecvQueryWaterMarkWithoutLock(const std::string QueryWaterMark queryWaterMark; int errCode = GetQueryWaterMarkInCacheAndDb(cacheKey, queryWaterMark); if (errCode != E_OK) { - LOGE("[Meta]SetRecvQueryWaterMarkWithoutLock GetQueryWaterMark error, errCode=%d", errCode); return errCode; } queryWaterMark.recvWaterMark = waterMark; @@ -249,7 +241,6 @@ int QuerySyncWaterMarkHelper::UpdateCacheAndSave(const std::string &cacheKey, // update lastUsedTime int errCode = OS::GetCurrentSysTimeInMicrosecond(queryWaterMark.lastUsedTime); if (errCode != E_OK) { - LOGE("[Meta]UpdateCacheAndSave GetCurrentSysTimeInMicrosecond failed, errCode=%d", errCode); return errCode; } // save db first @@ -265,7 +256,6 @@ int QuerySyncWaterMarkHelper::PutQueryWaterMarkToDB(const DeviceID &dbKeyString, { int errCode = OS::GetCurrentSysTimeInMicrosecond(queryWaterMark.lastUsedTime); if (errCode != E_OK) { - LOGE("[Meta]PutQueryWaterMarkToDB GetCurrentSysTimeInMicrosecond failed, errCode=%d", errCode); return errCode; } queryWaterMark.version = QUERY_WATERMARK_VERSION_CURRENT; @@ -278,7 +268,6 @@ int QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB(const DeviceID &dbKeyString Value dbValue; int errCode = SerializeQueryWaterMark(queryWaterMark, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB SerializeQueryWaterMark failed errCode=%d", errCode); return errCode; } // serialize key @@ -287,7 +276,7 @@ int QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB(const DeviceID &dbKeyString // save errCode = SetMetadataToDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB SetMetadataToDb failed errCode=%d", errCode); + LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB failed errCode:%d", errCode); } return errCode; } @@ -301,7 +290,6 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkFromDB(const DeviceID &dbKeyStrin Value dbValue; int errCode = GetMetadataFromDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::GetQueryWaterMarkFromDB GetMetadataFromDb failed errCode=%d", errCode); return errCode; } return DeSerializeQueryWaterMark(dbValue, queryWaterMark); @@ -446,7 +434,6 @@ int QuerySyncWaterMarkHelper::GetDeleteWaterMarkFromDB(const DeviceID &hashDevic Value dbValue; int errCode = GetMetadataFromDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::GetDeleteWaterMarkFromDB GetMetadataFromDb failed errCode=%d", errCode); return errCode; } // serialize value @@ -460,7 +447,6 @@ int QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB(const DeviceID &hashDevice Value dbValue; int errCode = SerializeDeleteWaterMark(deleteWaterMark, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB SerializeDeleteWaterMark failed errCode=%d", errCode); return errCode; } Key dbKey; @@ -468,7 +454,7 @@ int QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB(const DeviceID &hashDevice // save errCode = SetMetadataToDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB failed errCode=%d", errCode); + LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB failed errCode:%d", errCode); } return errCode; } @@ -598,7 +584,7 @@ int QuerySyncWaterMarkHelper::ResetRecvQueryWaterMark(const DeviceID &deviceId, DBCommon::StringToVector(prefixKeyStr, prefixKey); int errCode = storage_->DeleteMetaDataByPrefixKey(prefixKey); if (errCode != E_OK) { - LOGE("[META]ResetRecvQueryWaterMark fail errCode=%d", errCode); + LOGE("[META]ResetRecvQueryWaterMark fail errCode:%d", errCode); return errCode; } // clean cache diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp index 4127be1fa..2157f5065 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp @@ -35,7 +35,6 @@ void SingleVerDataMessageSchedule::Initialize(const std::string &label, const st void SingleVerDataMessageSchedule::PutMsg(Message *inMsg) { if (inMsg == nullptr) { - LOGE("[DataMsgSchedule] inMsg is nullptr"); return; } std::lock_guard lock(queueLock_); @@ -70,6 +69,7 @@ Message *SingleVerDataMessageSchedule::MoveNextMsg(SingleVerSyncTaskContext *con Message *msg = GetMsgFromMap(isNeedHandle); isNeedContinue = true; if (msg == nullptr) { + StopTimer(); std::lock_guard lock(workingLock_); isWorking_ = false; return nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp index 3958e63a1..0b52e0528 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp @@ -166,7 +166,6 @@ uint32_t DataRequestPacket::CalculateLen(uint32_t messageId) const } totalLen = Parcel::GetEightByteAlign(totalLen); // 8-byte align if (totalLen > INT32_MAX) { - LOGE("[DataRequestPacket][CalculateLen] Parcel GetEightByteAlign > INT32_MAX"); return 0; } if (messageId == QUERY_SYNC_MESSAGE) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp index f6e9ecce9..8946b09c7 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp @@ -521,7 +521,7 @@ int ValueSliceSync::GetValidValueSliceHashNode(MultiVerSyncTaskContext *context, int ValueSliceSync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT}; + SendConfig conf = {false, false, SEND_TIME_OUT, {}}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("ValueSliceSync::Send ERR! err = %d", errCode); diff --git a/services/distributeddataservice/service/kv/user_delegate.cpp b/services/distributeddataservice/service/kv/user_delegate.cpp index d8055cbef..3f35b4ed8 100644 --- a/services/distributeddataservice/service/kv/user_delegate.cpp +++ b/services/distributeddataservice/service/kv/user_delegate.cpp @@ -58,7 +58,7 @@ std::vector UserDelegate::GetUsers(const std::string &deviceId) for (const auto &entry : deviceUserMap_[deviceId]) { userStatus.emplace_back(entry.first, entry.second); } - ZLOGI("device=%{public}.10s, users=%{public}s", deviceId.c_str(), Serializable::Marshall(userStatus).c_str()); + ZLOGI("device:%{public}.10s, users:%{public}s", deviceId.c_str(), Serializable::Marshall(userStatus).c_str()); return userStatus; } @@ -69,7 +69,7 @@ void UserDelegate::DeleteUsers(const std::string &deviceId) void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector &userStatus) { - ZLOGI("begin, device=%{public}.10s, users=%{public}u", deviceId.c_str(), userStatus.size()); + ZLOGI("begin, device:%{public}.10s, users:%{public}u", deviceId.c_str(), userStatus.size()); deviceUserMap_.ComputeIfPresent(deviceId, [](const auto &key, std::map &userMap) { for (auto &user : userMap) { user.second = false; @@ -78,7 +78,7 @@ void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector osAccountIds = { { 0, true } }; // system user default auto ret = OsAccountManager::QueryActiveOsAccountIds(osAccountIds); if (ret != 0 || osAccountIds.empty()) { - ZLOGE("failed to query os accounts, ret=%{public}d", ret); + ZLOGE("failed to query os accounts, ret:%{public}d", ret); return false; } std::vector userStatus = { { 0, true } }; @@ -109,7 +109,7 @@ bool UserDelegate::InitLocalUserMeta() std::string jsonData = UserMetaData::Marshall(userMetaData); DistributedDB::Value dbValue{ jsonData.begin(), jsonData.end() }; ret = metaDelegate->Put(dbKey, dbValue); - ZLOGI("put user meta data ret=%{public}d", ret); + ZLOGI("put user meta data ret %{public}d", ret); return ret == DistributedDB::DBStatus::OK; } @@ -125,7 +125,7 @@ void UserDelegate::LoadFromMeta(const std::string &deviceId) DistributedDB::Value dbValue; auto ret = metaDelegate->Get(dbKey, dbValue); UserMetaData userMetaData; - ZLOGI("get user meta data ret=%{public}d", ret); + ZLOGI("get user meta data ret %{public}d", ret); if (ret != DistributedDB::DBStatus::OK) { return; } @@ -163,7 +163,7 @@ void UserDelegate::Init() [this](const std::vector &key, const std::vector &value, CHANGE_FLAG flag) { UserMetaData metaData; metaData.Unmarshall({ value.begin(), value.end() }); - ZLOGD("flag=%{public}d, value=%{public}.10s", flag, metaData.deviceId.c_str()); + ZLOGD("flag:%{public}d, value:%{public}.10s", flag, metaData.deviceId.c_str()); if (metaData.deviceId == DeviceKvStoreImpl::GetLocalDeviceId()) { ZLOGD("ignore local device user meta change"); return; @@ -176,7 +176,7 @@ void UserDelegate::Init() ZLOGD("ignored operation"); } }); - ZLOGD("subscribe os account ret=%{public}d", ret); + ZLOGD("subscribe os account ret:%{public}d", ret); } bool UserDelegate::NotifyUserEvent(const UserDelegate::UserEvent &userEvent) @@ -191,7 +191,7 @@ UserDelegate::LocalUserObserver::LocalUserObserver(UserDelegate &userDelegate) : void UserDelegate::LocalUserObserver::OnAccountChanged(const DistributedKv::AccountEventInfo &eventInfo) { - ZLOGI("event info=%{public}s, status=%{public}d", eventInfo.deviceAccountId.c_str(), eventInfo.status); + ZLOGI("event info:%{public}s, %{public}d", eventInfo.deviceAccountId.c_str(), eventInfo.status); userDelegate_.NotifyUserEvent({}); // just notify } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index c2e9f268e..1a98804fe 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -213,7 +213,6 @@ std::shared_ptr RdbServiceImpl::GetRdbSyncer(const RdbSyncerParam &pa } auto syncer_ = std::make_shared(param, new (std::nothrow) RdbStoreObserverImpl(this, pid)); if (syncer_->Init(pid, uid) != 0) { - ZLOGE("init syncer error"); return false; } syncers[param.storeName_] = syncer_; @@ -237,7 +236,6 @@ int32_t RdbServiceImpl::SetDistributedTables(const RdbSyncerParam ¶m, const ZLOGI("enter"); auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { - ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->SetDistributedTables(tables); @@ -248,7 +246,6 @@ int32_t RdbServiceImpl::DoSync(const RdbSyncerParam ¶m, const SyncOption &op { auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { - ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->DoSync(option, predicates, result); @@ -269,7 +266,6 @@ int32_t RdbServiceImpl::DoAsync(const RdbSyncerParam ¶m, uint32_t seqNum, co ZLOGI("seq num=%{public}u", seqNum); auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { - ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->DoAsync(option, predicates, diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp index 454226871..1de876eea 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp @@ -36,7 +36,6 @@ int32_t RdbServiceStub::OnRemoteObtainDistributedTableName(MessageParcel &data, return RDB_OK; } - ZLOGI("successful"); reply.WriteString(ObtainDistributedTableName(device, table)); return RDB_OK; } @@ -61,7 +60,7 @@ int32_t RdbServiceStub::OnRemoteInitNotifier(MessageParcel &data, MessageParcel reply.WriteInt32(error); return RDB_OK; } - ZLOGI("successful"); + ZLOGI("success"); reply.WriteInt32(RDB_OK); return RDB_OK; } @@ -103,12 +102,10 @@ int32_t RdbServiceStub::OnRemoteDoSync(MessageParcel &data, MessageParcel &reply SyncResult result; if (DoSync(param, option, predicates, result) != RDB_OK) { - ZLOGE("DoSync failed"); reply.WriteInt32(RDB_ERROR); return RDB_OK; } if (!DistributedKv::ITypesUtil::Marshalling(result, reply)) { - ZLOGE("Marshalling failed"); reply.WriteInt32(RDB_ERROR); return RDB_OK; } @@ -185,7 +182,6 @@ int RdbServiceStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageP { ZLOGI("code=%{public}d", code); if (!CheckInterfaceToken(data)) { - ZLOGE("check interface token failed"); return RDB_ERROR; } if (code >= 0 && code < RDB_SERVICE_CMD_MAX) { diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.cpp b/services/distributeddataservice/service/rdb/rdb_syncer.cpp index 2856a5059..a1813e3b2 100644 --- a/services/distributeddataservice/service/rdb/rdb_syncer.cpp +++ b/services/distributeddataservice/service/rdb/rdb_syncer.cpp @@ -101,7 +101,7 @@ int32_t RdbSyncer::Init(pid_t pid, pid_t uid) ZLOGE("create meta data failed"); return RDB_ERROR; } - ZLOGI("successful"); + ZLOGI("success"); return RDB_OK; } @@ -153,7 +153,7 @@ DistributedDB::RelationalStoreDelegate* RdbSyncer::GetDelegate() ZLOGE("open store failed status=%{public}d", status); return nullptr; } - ZLOGI("open store successful"); + ZLOGI("open store success"); } return delegate_; @@ -174,7 +174,7 @@ int32_t RdbSyncer::SetDistributedTables(const std::vector &tables) return RDB_ERROR; } } - ZLOGE("create distributed table successful"); + ZLOGE("create distributed table success"); return RDB_OK; } -- Gitee From 7e8d251bf037bf7eeb78613f27ae596537dd945c Mon Sep 17 00:00:00 2001 From: "kaixuan.shao" Date: Mon, 21 Mar 2022 16:16:33 +0800 Subject: [PATCH 3/3] log fix --- .../app_distributed_kv_data_manager_impl.cpp | 20 ++-- .../src/app_kvstore_impl.cpp | 55 +++++++++-- .../src/app_kvstore_result_set_impl.cpp | 3 + .../src/change_notification.cpp | 13 ++- .../src/distributed_kv_data_manager.cpp | 8 +- .../distributeddatafwk/src/ikvstore.cpp | 48 ++++----- .../src/ikvstore_data_service.cpp | 50 +++++++--- .../src/ikvstore_resultset.cpp | 16 +-- .../src/ikvstore_single.cpp | 98 ++++++++++++------- .../src/ikvstore_snapshot.cpp | 26 +++-- .../distributeddatafwk/src/itypes_util.cpp | 21 ++++ .../distributeddatafwk/src/kvstore_client.cpp | 8 +- .../src/kvstore_resultset_client.cpp | 5 +- .../src/kvstore_service_death_notifier.cpp | 11 ++- .../src/kvstore_snapshot_client.cpp | 2 + .../src/single_kvstore_client.cpp | 15 ++- .../rdb/src/rdb_manager_impl.cpp | 7 +- .../innerkitsimpl/rdb/src/rdb_notifier.cpp | 2 + .../rdb/src/rdb_service_proxy.cpp | 15 +-- .../distributeddata/src/entry_point.cpp | 10 +- .../src/js_device_kv_store.cpp | 25 ++--- .../distributeddata/src/js_field_node.cpp | 3 + .../distributeddata/src/js_kv_manager.cpp | 21 ++-- .../distributeddata/src/js_kv_store.cpp | 37 ++++--- .../src/js_kv_store_resultset.cpp | 3 +- .../distributeddata/src/js_query.cpp | 9 ++ .../distributeddata/src/js_schema.cpp | 5 + .../src/js_single_kv_store.cpp | 23 ++--- .../distributeddata/src/js_util.cpp | 5 +- .../distributeddata/src/napi_queue.cpp | 2 + .../src/softbus_adapter_standard.cpp | 2 +- .../storage/src/operation/database_oper.cpp | 2 + .../sqlite_relational_store_connection.cpp | 1 + .../distributeddb/syncer/src/ability_sync.cpp | 91 ++++++++++++----- .../syncer/src/commit_history_sync.cpp | 60 ++++++++++-- .../syncer/src/communicator_proxy.cpp | 3 + .../syncer/src/device_manager.cpp | 7 +- .../syncer/src/generic_syncer.cpp | 44 ++++++--- .../distributeddb/syncer/src/meta_data.cpp | 39 ++++++-- .../syncer/src/multi_ver_data_sync.cpp | 51 ++++++++-- .../src/multi_ver_sync_state_machine.cpp | 46 ++++++--- .../src/multi_ver_sync_task_context.cpp | 6 +- .../syncer/src/multi_ver_syncer.cpp | 9 +- .../src/query_sync_water_mark_helper.cpp | 22 ++++- .../src/single_ver_data_message_schedule.cpp | 2 +- .../syncer/src/single_ver_data_packet.cpp | 1 + .../syncer/src/value_slice_sync.cpp | 2 +- .../service/kv/user_delegate.cpp | 18 ++-- .../service/rdb/rdb_service_impl.cpp | 4 + .../service/rdb/rdb_service_stub.cpp | 6 +- .../service/rdb/rdb_syncer.cpp | 6 +- 51 files changed, 691 insertions(+), 297 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp index afa655fa4..fc004122b 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_distributed_kv_data_manager_impl.cpp @@ -47,11 +47,12 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge std::lock_guard lck(storeMutex_); auto it = managers_.find(bundleName + userId); if (it != managers_.end()) { + ZLOGI("manager has been found"); return it->second; } std::string tempDataDir = dataDir; - ZLOGD("tempDataDir : %s", tempDataDir.c_str()); + ZLOGD("tempDataDir = %s", tempDataDir.c_str()); if (!ForceCreateDirectory(tempDataDir)) { ZLOGE("create directories %s failed", tempDataDir.c_str()); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_CREATE_DIR}; @@ -60,6 +61,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge } // default mode is 0755 if (!ChangeModeDirectory(tempDataDir, DistributedKv::Constant::DEFAULT_MODE)) { + ZLOGI("tempDataDir is default mode."); return nullptr; } @@ -69,7 +71,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge } auto status = DistributedDB::KvStoreDelegateManager::SetProcessLabel(appId + DEVICE_COLLABORATION_ABBRE, userId); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("delegate SetProcessLabel failed: %d.", static_cast(status)); + ZLOGE("delegate SetProcessLabel failed=%d.", static_cast(status)); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_PROCESS_LABEL}; Reporter::GetInstance()->ServiceFault()->Report(msg); return nullptr; @@ -78,7 +80,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge auto communicator = std::make_shared(); auto commStatus = DistributedDB::KvStoreDelegateManager::SetProcessCommunicator(communicator); if (commStatus != DistributedDB::DBStatus::OK) { - ZLOGW("set distributed db communicator failed."); + ZLOGW("set distributed db communicator failed=%d.", static_cast(status)); return nullptr; } @@ -90,7 +92,7 @@ std::shared_ptr AppDistributedKvDataManagerImpl::Ge DistributedDB::KvStoreConfig kvStoreConfig { tempDataDir }; status = delegateManager->SetKvStoreConfig(kvStoreConfig); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("delegate SetKvStoreConfig failed: %d.", static_cast(status)); + ZLOGE("delegate SetKvStoreConfig failed=%d.", static_cast(status)); FaultMsg msg = {FaultType::SERVICE_FAULT, "device", "GetInstance", Fault::SF_DATABASE_CONFIG}; Reporter::GetInstance()->ServiceFault()->Report(msg); delete delegateManager; @@ -166,7 +168,7 @@ Status AppDistributedKvDataManagerImpl::GetKvStore( Reporter::GetInstance()->ServiceFault()->Report(msg); }); - ZLOGI("get status: %d.", static_cast(status)); + ZLOGI("get status=%d.", static_cast(status)); return status; } @@ -201,7 +203,7 @@ Status AppDistributedKvDataManagerImpl::DeleteKvStore(const std::string &storeId ZLOGI("delete KVStore succeed."); return Status::SUCCESS; } - ZLOGE("delete KVStore failed."); + ZLOGE("delete KVStore failed, status=%d", static_cast(status)); return Status::ERROR; } @@ -214,10 +216,10 @@ Status AppDistributedKvDataManagerImpl::GetKvStoreDiskSize(const std::string &st } DistributedDB::DBStatus status = kvStoreDelegateManager_->GetKvStoreDiskSize(storeId, size); if (status != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to getStoreDiskSize, storeID: %s", storeId.c_str()); + ZLOGE("Failed to getStoreDiskSize, storeID: %s, status=%d", storeId.c_str(), static_cast(status)); return Status::ERROR; } - ZLOGI("end, size:%" PRIu64, size); + ZLOGI("end, size=%" PRIu64, size); return Status::SUCCESS; } @@ -233,6 +235,7 @@ Status AppDistributedKvDataManagerImpl::RegisterKvStoreCorruptionObserver( return Status::REPEATED_REGISTER; } if (kvStoreDelegateManager_ == nullptr) { + ZLOGE("kvStoreDelegateManager_ is nullptr."); return Status::ERROR; } corruptionObserver_ = observer; @@ -247,6 +250,7 @@ Status AppDistributedKvDataManagerImpl::RegisterKvStoreCorruptionObserver( DistributedDB::SecurityOption AppDistributedKvDataManagerImpl::ConvertSecurityLevel(int securityLevel) { if (securityLevel < SecurityLevel::NO_LABEL || securityLevel > SecurityLevel::S4) { + ZLOGD("SecurityLevel not correct"); return {SecurityLevel::NO_LABEL, DistributedDB::ECE}; } switch (securityLevel) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp index 2ce544b7a..7e4080a71 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_impl.cpp @@ -86,7 +86,7 @@ Status AppKvStoreImpl::Put(const WriteOptions &options, const Key &key, const Va Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGW("put failed. status: %d.", static_cast(status)); + ZLOGE("put failed. status=%d.", static_cast(status)); return ConvertErrorCode(status); } @@ -111,7 +111,7 @@ Status AppKvStoreImpl::Delete(const WriteOptions &options, const Key &key) Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } - ZLOGW("failed status: %d.", static_cast(status)); + ZLOGE("failed status=%d.", static_cast(status)); return ConvertErrorCode(status); } @@ -124,6 +124,7 @@ Status AppKvStoreImpl::Get(const ReadOptions &options, const Key &key, Value &va ZLOGD("start"); auto trimmedKey = DistributedKv::Constant::TrimCopy>(key.Data()); if (trimmedKey.size() == 0 || trimmedKey.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { + ZLOGE("trimmedKey size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKey = trimmedKey; @@ -142,6 +143,7 @@ Status AppKvStoreImpl::Get(const ReadOptions &options, const Key &key, Value &va Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); return Status::SUCCESS; } + ZLOGE("get key-value error, errCode=%d", status); return ConvertErrorCode(status); } @@ -154,6 +156,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr ZLOGD("start."); auto trimmedPrefix = DistributedKv::Constant::TrimCopy>(prefixKey.Data()); if (trimmedPrefix.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { + ZLOGE("trimmedPrefix size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKeyPrefix = trimmedPrefix; @@ -161,7 +164,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr DistributedDB::DBStatus status = kvStoreNbDelegate_->GetEntries(tmpKeyPrefix, dbEntries); if (status == DistributedDB::DBStatus::OK) { entries.reserve(dbEntries.size()); - ZLOGD("vector size: %zu status: %d.", dbEntries.size(), static_cast(status)); + ZLOGD("vector size=%zu status=%d.", dbEntries.size(), static_cast(status)); for (auto const &dbEntry : dbEntries) { Key tmpKey(dbEntry.key); Value tmpValue(dbEntry.value); @@ -169,6 +172,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, std::vector &entr } return Status::SUCCESS; } + ZLOGE("get entries error, errCode=%d", status); return ConvertErrorCode(status); } @@ -178,6 +182,7 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, AppKvStoreResultSet *&re ZLOGD("start."); auto trimmedPrefix = DistributedKv::Constant::TrimCopy>(prefixKey.Data()); if (trimmedPrefix.size() > DistributedKv::Constant::MAX_KEY_LENGTH) { + ZLOGE("trimmedPrefix size error."); return Status::INVALID_ARGUMENT; } DistributedDB::Key tmpKeyPrefix = trimmedPrefix; @@ -186,41 +191,50 @@ Status AppKvStoreImpl::GetEntries(const Key &prefixKey, AppKvStoreResultSet *&re if (status == DistributedDB::DBStatus::OK) { resultSet = new (std::nothrow) AppKvStoreResultSetImpl(dbResultSet, kvStoreNbDelegate_); if (resultSet == nullptr) { - ZLOGW("new resultSet failed."); + ZLOGE("new resultSet failed."); return Status::ERROR; } return Status::SUCCESS; } + ZLOGE("get entries error, errCode=%d", status); return ConvertErrorCode(status); } // Close the result set returned by GetEntries(). Status AppKvStoreImpl::CloseResultSet(AppKvStoreResultSet *&resultSet) { + ZLOGD("start."); if (resultSet == nullptr) { + ZLOGE("resultSet is nullptr"); return Status::INVALID_ARGUMENT; } if (resultSet->Close() == Status::SUCCESS) { + ZLOGD("successful."); delete resultSet; resultSet = nullptr; return Status::SUCCESS; } + ZLOGE("close resultSet error."); return Status::ERROR; } // Close this kvstore in KvStoreDelegateManager. This method is called before this store object destruct. Status AppKvStoreImpl::Close(DistributedDB::KvStoreDelegateManager *kvStoreDelegateManager) { + ZLOGD("start."); if (kvStoreDelegateManager == nullptr) { + ZLOGE("kvStoreDelegateManager is nullptr"); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus status = kvStoreDelegateManager->CloseKvStore(kvStoreNbDelegate_); if (status == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); VisitStat vs { appId_, __FUNCTION__ }; Reporter::GetInstance()->VisitStatistic()->Report(vs); return Status::SUCCESS; } + ZLOGE("close KvStore error, errCode=%d", status); return Status::ERROR; } @@ -270,7 +284,7 @@ Status AppKvStoreImpl::Sync(const std::vector &deviceIds, SyncMode callback(resultMap); }); - ZLOGD("end: %d", static_cast(status)); + ZLOGD("end=%d", static_cast(status)); Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (status == DistributedDB::DBStatus::OK) { return Status::SUCCESS; @@ -293,6 +307,7 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr { ZLOGD("start."); if (observer == nullptr) { + ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus dbStatus; @@ -306,6 +321,7 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr std::lock_guard lock(localObserverMapMutex_); bool alreadySubscribed = (localObserverMap_.find(observer) != localObserverMap_.end()); if (alreadySubscribed) { + ZLOGD("store alreadly subscribe."); delete nbObserver; return Status::STORE_ALREADY_SUBSCRIBE; } @@ -313,12 +329,14 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr dbStatus = kvStoreNbDelegate_->RegisterObserver( emptyKey, DistributedDB::ObserverMode::OBSERVER_CHANGES_LOCAL_ONLY, nbObserver); if (dbStatus == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); localObserverMap_.insert(std::pair(observer, nbObserver)); } } else { std::lock_guard lock(syncedObserverMapMutex_); bool alreadySubscribed = (syncedObserverMap_.find(observer) != syncedObserverMap_.end()); if (alreadySubscribed) { + ZLOGD("store alreadly subscribe."); delete nbObserver; return Status::STORE_ALREADY_SUBSCRIBE; } @@ -338,16 +356,20 @@ Status AppKvStoreImpl::SubscribeKvStore(const ReadOptions &options, const Subscr } Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (dbStatus == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); return Status::SUCCESS; } delete nbObserver; if (dbStatus == DistributedDB::DBStatus::INVALID_ARGS) { + ZLOGE("Invalid args."); return Status::INVALID_ARGUMENT; } if (dbStatus == DistributedDB::DBStatus::DB_ERROR) { + ZLOGE("db error."); return Status::DB_ERROR; } + ZLOGE("error."); return Status::ERROR; } @@ -365,6 +387,7 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs { ZLOGD("start."); if (observer == nullptr) { + ZLOGE("observer is nullptr."); return Status::INVALID_ARGUMENT; } DistributedDB::DBStatus dbStatus; @@ -372,6 +395,7 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs std::lock_guard lock(localObserverMapMutex_); auto nbObserver = localObserverMap_.find(observer); if (nbObserver == localObserverMap_.end()) { + ZLOGD("store not subscribe"); return Status::STORE_NOT_SUBSCRIBE; } dbStatus = kvStoreNbDelegate_->UnRegisterObserver(nbObserver->second); @@ -383,6 +407,7 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs std::lock_guard lock(syncedObserverMapMutex_); auto nbObserver = syncedObserverMap_.find(observer); if (nbObserver == syncedObserverMap_.end()) { + ZLOGD("store not subscribe."); return Status::STORE_NOT_SUBSCRIBE; } dbStatus = kvStoreNbDelegate_->UnRegisterObserver(nbObserver->second); @@ -393,14 +418,18 @@ Status AppKvStoreImpl::UnSubscribeKvStore(const ReadOptions &options, const Subs } Reporter::GetInstance()->VisitStatistic()->Report({appId_, __FUNCTION__}); if (dbStatus == DistributedDB::DBStatus::OK) { + ZLOGD("successful."); return Status::SUCCESS; } if (dbStatus == DistributedDB::DBStatus::NOT_FOUND) { + ZLOGE("store not subscribe.."); return Status::STORE_NOT_SUBSCRIBE; } if (dbStatus == DistributedDB::DBStatus::INVALID_ARGS) { + ZLOGE("invalid args."); return Status::INVALID_ARGUMENT; } + ZLOGE("db error."); return Status::ERROR; } @@ -411,6 +440,7 @@ Status AppKvStoreImpl::RemoveDeviceData(const std::string &device) if (status == DistributedDB::DBStatus::OK) { return Status::SUCCESS; } + ZLOGW("RemoveDeviceData error, errCode=%d", status); return Status::ERROR; } @@ -429,6 +459,7 @@ Status AppKvStoreImpl::SetConflictResolutionPolicy( callback(appConflictDataImpl); }); if (dbStatus != DistributedDB::DBStatus::OK) { + ZLOGE("error, status=%d", dbStatus); return Status::DB_ERROR; } return Status::SUCCESS; @@ -437,6 +468,7 @@ Status AppKvStoreImpl::SetConflictResolutionPolicy( void AppKvStoreImpl::FormKvStoreConflictEntry(const DistributedDB::KvStoreNbConflictData &data, KvStoreConflictEntry &kvstoreConflictEntry) { + ZLOGD("start."); kvstoreConflictEntry.type = data.GetType(); DistributedDB::Key dbKey; data.GetKey(dbKey); @@ -452,6 +484,7 @@ void AppKvStoreImpl::FormKvStoreConflictData(const DistributedDB::KvStoreNbConfl DistributedDB::KvStoreNbConflictData::ValueType type, KvStoreConflictData &kvStoreConflictData) { + ZLOGD("start."); DistributedDB::DBStatus dbStatus; kvStoreConflictData.isLocal = data.IsNative(type); kvStoreConflictData.isDeleted = data.IsDeleted(type); @@ -459,7 +492,7 @@ void AppKvStoreImpl::FormKvStoreConflictData(const DistributedDB::KvStoreNbConfl DistributedDB::Value dbValue; dbStatus = data.GetValue(type, dbValue); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to handle conflict, error: bad conflict data"); + ZLOGE("Failed to handle conflict, error: bad conflict data status=%d", dbStatus); kvStoreConflictData.status = Status::DB_ERROR; return; } @@ -473,17 +506,18 @@ Status AppKvStoreImpl::Export(const std::string &filePath, const std::vectorExport(filePath, password); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to export, path:%s", filePath.c_str()); + ZLOGE("Failed to export, path=%s, status=%d", filePath.c_str(), dbStatus); return Status::DB_ERROR; } ZLOGD("export end"); @@ -494,17 +528,18 @@ Status AppKvStoreImpl::Import(const std::string &filePath, const std::vectorImport(filePath, password); if (dbStatus != DistributedDB::DBStatus::OK) { - ZLOGE("Failed to export, path:%s", filePath.c_str()); + ZLOGE("Failed to export, path=%s, status=%d", filePath.c_str(), dbStatus); return Status::DB_ERROR; } ZLOGD("Import end"); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp index 0cecd9a0f..0c76ba3c3 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/app_kvstore_result_set_impl.cpp @@ -17,6 +17,7 @@ #include "app_kvstore_result_set_impl.h" #include "app_types.h" +#include "log_print.h" namespace OHOS { namespace AppDistributedKv { @@ -110,9 +111,11 @@ bool AppKvStoreResultSetImpl::IsAfterLast() const Status AppKvStoreResultSetImpl::GetEntry(Entry &entry) const { if (kvStoreResultSet_ == nullptr) { + ZLOGD("kvStoreResultSet_ is nullptr"); return Status::ERROR; } if (GetCount() == 0) { + ZLOGD("count is zero"); return Status::KEY_NOT_FOUND; } DistributedDB::Entry dbEntry; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp index 1a7a14a09..8d57dc012 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/change_notification.cpp @@ -58,35 +58,42 @@ bool ChangeNotification::IsClear() const bool ChangeNotification::Marshalling(Parcel &parcel) const { if (!parcel.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGE("SetMaxCapacity MAX_IPC_CAPACITY failed."); return false; } int32_t lenInsert = static_cast(insertEntries_.size()); if (!parcel.WriteInt32(lenInsert)) { + ZLOGE("WriteInt32 lenInsert failed."); return false; } for (const auto &entry : insertEntries_) { if (!parcel.WriteParcelable(&entry)) { + ZLOGE("WriteParcelable insertEntries_ entrys failed."); return false; } } int32_t lenUpdate = static_cast(updateEntries_.size()); if (!parcel.WriteInt32(lenUpdate)) { + ZLOGE("WriteInt32 lenUpdate failed."); return false; } for (const auto &entry : updateEntries_) { if (!parcel.WriteParcelable(&entry)) { + ZLOGE("WriteParcelable updateEntries_ entrys failed."); return false; } } int32_t lenDelete = static_cast(deleteEntries_.size()); if (!parcel.WriteInt32(lenDelete)) { + ZLOGE("WriteInt32 lenDelete failed."); return false; } for (const auto &entry : deleteEntries_) { if (!parcel.WriteParcelable(&entry)) { + ZLOGE("WriteParcelable deleteEntries_ entrys failed."); return false; } } @@ -106,7 +113,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenInsert = parcel.ReadInt32(); if (lenInsert < 0) { - ZLOGE("lenInsert is %d", lenInsert); + ZLOGE("lenInsert = %d", lenInsert); return nullptr; } for (int i = 0; i < lenInsert; i++) { @@ -121,7 +128,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenUpdate = parcel.ReadInt32(); if (lenUpdate < 0) { - ZLOGE("lenUpdate is %d", lenUpdate); + ZLOGE("lenUpdate = %d", lenUpdate); return nullptr; } for (int i = 0; i < lenUpdate; i++) { @@ -136,7 +143,7 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel) int lenDelete = parcel.ReadInt32(); if (lenDelete < 0) { - ZLOGE("lenDelete is %d", lenDelete); + ZLOGE("lenDelete = %d", lenDelete); return nullptr; } for (int i = 0; i < lenDelete; i++) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp index 58894cf8a..6385d6aaf 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp @@ -60,13 +60,13 @@ Status DistributedKvDataManager::GetKvStore(const Options &options, const AppId status = kvDataServiceProxy->GetKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (status == Status::RECOVER_SUCCESS) { - ZLOGE("proxy recover success: %d", static_cast(status)); + ZLOGE("proxy recover success=%d", static_cast(status)); kvStore = std::make_shared(std::move(proxyTmp), storeIdTmp); return status; } if (status != Status::SUCCESS) { - ZLOGE("proxy return error: %d", static_cast(status)); + ZLOGE("proxy return error=%d", static_cast(status)); return status; } @@ -103,13 +103,13 @@ Status DistributedKvDataManager::GetSingleKvStore(const Options &options, const status = kvDataServiceProxy->GetSingleKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (status == Status::RECOVER_SUCCESS) { - ZLOGE("proxy recover success: %d", static_cast(status)); + ZLOGE("proxy recover success=%d", static_cast(status)); singleKvStore = std::make_shared(std::move(proxyTmp), storeIdTmp); return status; } if (status != Status::SUCCESS) { - ZLOGE("proxy return error: %d", static_cast(status)); + ZLOGE("proxy return error=%d", static_cast(status)); return status; } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp index 64500b51c..9609d6051 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore.cpp @@ -45,6 +45,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, std::function)> callback) { if (observer == nullptr) { + ZLOGW("observer is nullptr"); callback(Status::INVALID_ARGUMENT, nullptr); return; } @@ -62,7 +63,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETKVSTORESNAPSHOT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); callback(Status::IPC_ERROR, nullptr); return; } @@ -70,6 +71,7 @@ void KvStoreImplProxy::GetKvStoreSnapshot(sptr observer, if (status == Status::SUCCESS) { sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject is nullptr"); callback(status, nullptr); return; } @@ -100,7 +102,7 @@ Status KvStoreImplProxy::ReleaseKvStoreSnapshot(sptr kvSto MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(RELEASEKVSTORESNAPSHOT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -133,7 +135,7 @@ Status KvStoreImplProxy::Put(const Key &key, const Value &value) MessageOption mo { MessageOption::TF_SYNC }; int error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed with error code %d", error); + ZLOGW("SendRequest failed with error code=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -158,7 +160,7 @@ Status KvStoreImplProxy::Put(const Key &key, const Value &value) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -183,6 +185,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) int64_t bufferSize = 0; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { + ZLOGW("entrty size too long."); return Status::INVALID_ARGUMENT; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -200,6 +203,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) } MessageOption mo { MessageOption::TF_SYNC }; if (Remote()->SendRequest(PUTBATCH, data, reply, mo) != 0) { + ZLOGW("Remote SendRequest failed."); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -229,7 +233,7 @@ Status KvStoreImplProxy::PutBatch(const std::vector &entries) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUTBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -249,7 +253,7 @@ Status KvStoreImplProxy::Delete(const Key &key) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -283,7 +287,7 @@ Status KvStoreImplProxy::DeleteBatch(const std::vector &keys) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -299,7 +303,7 @@ Status KvStoreImplProxy::Clear() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLEAR, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -315,7 +319,7 @@ Status KvStoreImplProxy::StartTransaction() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTTRANSACTION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -331,7 +335,7 @@ Status KvStoreImplProxy::Commit() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(COMMIT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -347,7 +351,7 @@ Status KvStoreImplProxy::Rollback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(ROLLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -374,7 +378,7 @@ Status KvStoreImplProxy::SubscribeKvStore(const SubscribeType subscribeType, spt MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -383,6 +387,7 @@ Status KvStoreImplProxy::SubscribeKvStore(const SubscribeType subscribeType, spt Status KvStoreImplProxy::UnSubscribeKvStore(const SubscribeType subscribeType, sptr observer) { if (observer == nullptr) { + ZLOGW("observer is invalid."); return Status::INVALID_ARGUMENT; } @@ -400,7 +405,7 @@ Status KvStoreImplProxy::UnSubscribeKvStore(const SubscribeType subscribeType, s MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest error=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -410,6 +415,7 @@ int32_t KvStoreImplStub::GetKvStoreSnapshotOnRemote(MessageParcel &data, Message { sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("remote is nullptr."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write obj failed."); return -1; @@ -460,11 +466,12 @@ int32_t KvStoreImplStub::PutOnRemoteRequest(MessageParcel &data, MessageParcel & return -1; } const int bufferSize = data.ReadInt32(); - ZLOGD("bufferSize %d", bufferSize); + ZLOGD("bufferSize=%d", bufferSize); if (bufferSize < Constant::SWITCH_RAW_DATA_SIZE) { sptr key = data.ReadParcelable(); sptr value = data.ReadParcelable(); if (key == nullptr || value == nullptr) { + ZLOGW("key or value is nullptr."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write key or val status failed."); return -1; @@ -473,7 +480,7 @@ int32_t KvStoreImplStub::PutOnRemoteRequest(MessageParcel &data, MessageParcel & } Status status = Put(*key, *value); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("write ret status failed."); + ZLOGW("write *ret status failed."); return -1; } return 0; @@ -513,9 +520,8 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar } int len = data.ReadInt32(); if (len < 0) { - ZLOGW("invalid status. len %d", len); + ZLOGW("invalid status. len=%d", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("write putbatch failed."); return -1; } return 0; @@ -528,7 +534,6 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (entry == nullptr) { ZLOGW("putbatch got null entry pointer"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { - ZLOGW("write putbatch failed."); return -1; } return 0; @@ -547,7 +552,6 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (buffer == nullptr) { ZLOGW("buffer is null"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { - ZLOGW("write putbatch big failed."); return -1; } return 0; @@ -563,7 +567,6 @@ int32_t KvStoreImplStub::PutBatchOnRemoteRequest(MessageParcel &data, MessagePar if (!success) { ZLOGW("get key or value failed"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { - ZLOGW("write putbatch big failed."); return -1; } return 0; @@ -582,7 +585,6 @@ int32_t KvStoreImplStub::DeleteOnRemoteRequest(MessageParcel &data, MessageParce if (key == nullptr) { ZLOGW("key nullptr after ipc"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { - ZLOGW("write delete failed."); return -1; } return 0; @@ -598,7 +600,7 @@ int32_t KvStoreImplStub::DeleteBatchOnRemoteRequest(MessageParcel &data, Message { int len = data.ReadInt32(); if (len < 0) { - ZLOGW("len %d invalid after ipc", len); + ZLOGW("len=%d invalid after ipc", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write delete failed."); return -1; @@ -629,6 +631,7 @@ int32_t KvStoreImplStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessagePa { int32_t type = data.ReadInt32(); if (type < 0) { + ZLOGW("type=%d invalid after ipc", type); return -1; } SubscribeType subscribeType = static_cast(type); @@ -652,6 +655,7 @@ int32_t KvStoreImplStub::UnSubscribeKvStoreOnRemote(MessageParcel &data, Message { int32_t type = data.ReadInt32(); if (type < 0) { + ZLOGW("type=%d invalid after ipc", type); return -1; } SubscribeType subscribeType = static_cast(type); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp index 068c6a147..8e126f6c2 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_data_service.cpp @@ -36,7 +36,7 @@ KvStoreDataServiceProxy::KvStoreDataServiceProxy(const sptr &impl Status KvStoreDataServiceProxy::GetKvStore(const Options &options, const AppId &appId, const StoreId &storeId, std::function)> callback) { - ZLOGI("%s %s", appId.appId.c_str(), storeId.storeId.c_str()); + ZLOGI("appId=%s storeId=%s", appId.appId.c_str(), storeId.storeId.c_str()); MessageParcel data; MessageParcel reply; @@ -86,7 +86,7 @@ Status KvStoreDataServiceProxy::GetKvStore(const Options &options, const AppId & Status KvStoreDataServiceProxy::GetSingleKvStore(const Options &options, const AppId &appId, const StoreId &storeId, std::function)> callback) { - ZLOGI("%s %s", appId.appId.c_str(), storeId.storeId.c_str()); + ZLOGI("appId=%s storeId=%s", appId.appId.c_str(), storeId.storeId.c_str()); MessageParcel data; MessageParcel reply; if (!data.WriteInterfaceToken(KvStoreDataServiceProxy::GetDescriptor())) { @@ -121,7 +121,7 @@ Status KvStoreDataServiceProxy::GetSingleKvStore(const Options &options, const A MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETSINGLEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -154,7 +154,7 @@ void KvStoreDataServiceProxy::GetAllKvStoreId(const AppId &appId, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETALLKVSTOREID, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); callback(Status::IPC_ERROR, storeIds); return; } @@ -183,7 +183,7 @@ Status KvStoreDataServiceProxy::CloseKvStore(const AppId &appId, const StoreId & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -205,7 +205,7 @@ Status KvStoreDataServiceProxy::CloseAllKvStore(const AppId &appId) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSEALLKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -227,7 +227,7 @@ Status KvStoreDataServiceProxy::DeleteKvStore(const AppId &appId, const StoreId MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -249,7 +249,7 @@ Status KvStoreDataServiceProxy::DeleteAllKvStore(const AppId &appId) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEALLKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -273,13 +273,14 @@ Status KvStoreDataServiceProxy::RegisterClientDeathObserver(const AppId &appId, return Status::IPC_ERROR; } } else { + ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REGISTERCLIENTDEATHOBSERVER, data, reply, mo); if (error != 0) { - ZLOGW("failed during IPC. errCode %d", error); + ZLOGW("failed during IPC. errCode=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -296,7 +297,7 @@ Status KvStoreDataServiceProxy::GetLocalDevice(OHOS::DistributedKv::DeviceInfo & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETLOCALDEVICE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -321,7 +322,7 @@ Status KvStoreDataServiceProxy::GetDeviceList(std::vector &deviceInf MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETDEVICELIST, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); @@ -353,16 +354,18 @@ Status KvStoreDataServiceProxy::StartWatchDeviceChange(sptrAsObject().GetRefPtr())) { + ZLOGW("WriteRemoteObject observer failed."); return Status::IPC_ERROR; } } else { + ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageParcel reply; MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTWATCHDEVICECHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -377,16 +380,18 @@ Status KvStoreDataServiceProxy::StopWatchDeviceChange(sptrAsObject().GetRefPtr())) { + ZLOGW("WriteRemoteObject observer failed."); return Status::IPC_ERROR; } } else { + ZLOGW("observer is nullptr."); return Status::INVALID_ARGUMENT; } MessageParcel reply; MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STOPWATCHDEVICECHANGE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -405,7 +410,7 @@ sptr KvStoreDataServiceProxy::GetRdbService() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GET_RDB_SERVICE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %{public}d", error); + ZLOGE("SendRequest returned=%{public}d", error); return nullptr; } auto remoteObject = reply.ReadRemoteObject(); @@ -444,6 +449,7 @@ int32_t KvStoreDataServiceStub::GetKvStoreOnRemote(MessageParcel &data, MessageP Status status = GetKvStore(options, appId, storeId, [&proxyTmp](sptr proxy) { proxyTmp = std::move(proxy); }); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } if (proxyTmp == nullptr) { @@ -469,10 +475,12 @@ int32_t KvStoreDataServiceStub::GetAllKvStoreIdOnRemote(MessageParcel &data, Mes }); if (!reply.WriteStringVector(storeIdList)) { + ZLOGW("write storeIdList failed."); return -1; } if (!reply.WriteInt32(static_cast(statusTmp))) { + ZLOGW("write statusTmp failed."); return -1; } return 0; @@ -483,15 +491,18 @@ int32_t KvStoreDataServiceStub::GetDeviceListOnRemote(MessageParcel &data, Messa DeviceFilterStrategy strategy = static_cast(data.ReadInt32()); Status status = GetDeviceList(infos, strategy); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } if (status == Status::SUCCESS) { if (!reply.WriteInt32(infos.size())) { + ZLOGW("write infos failed."); return -1; } for (DeviceInfo const &info : infos) { if (!reply.WriteString(info.deviceId) || !reply.WriteString(info.deviceName) || !reply.WriteString(info.deviceType)) { + ZLOGW("write info failed."); return -1; } } @@ -512,6 +523,7 @@ int32_t KvStoreDataServiceStub::StartWatchDeviceChangeOnRemote(MessageParcel &da sptr observerProxy = iface_cast(remote); Status status = StartWatchDeviceChange(std::move(observerProxy), strategy); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -529,6 +541,7 @@ int32_t KvStoreDataServiceStub::StopWatchDeviceChangeOnRemote(MessageParcel &dat sptr observerProxy = iface_cast(remote); Status status = StopWatchDeviceChange(std::move(observerProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -562,10 +575,12 @@ int32_t KvStoreDataServiceStub::GetSingleKvStoreOnRemote(MessageParcel &data, Me Status status = GetSingleKvStore(options, appId, storeId, [&](sptr proxy) { proxyTmp = std::move(proxy); }); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } if (status == Status::SUCCESS && proxyTmp != nullptr) { if (!reply.WriteRemoteObject(proxyTmp->AsObject().GetRefPtr())) { + ZLOGW("WriteRemoteObject proxyTmp failed."); return -1; } } @@ -578,6 +593,7 @@ int32_t KvStoreDataServiceStub::CloseKvStoreOnRemote(MessageParcel &data, Messag StoreId storeId = { Constant::TrimCopy(data.ReadString())}; Status status = CloseKvStore(appId, storeId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -588,6 +604,7 @@ int32_t KvStoreDataServiceStub::CloseAllKvStoreOnRemote(MessageParcel &data, Mes AppId appId = { Constant::TrimCopy(data.ReadString())}; Status status = CloseAllKvStore(appId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -599,6 +616,7 @@ int32_t KvStoreDataServiceStub::DeleteKvStoreOnRemote(MessageParcel &data, Messa StoreId storeId = { Constant::TrimCopy(data.ReadString())}; Status status = DeleteKvStore(appId, storeId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -609,6 +627,7 @@ int32_t KvStoreDataServiceStub::DeleteAllKvStoreOnRemote(MessageParcel &data, Me AppId appId = { Constant::TrimCopy(data.ReadString())}; Status status = DeleteAllKvStore(appId); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -619,10 +638,12 @@ int32_t KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote(MessageParce AppId appId = { Constant::TrimCopy(data.ReadString())}; sptr kvStoreClientDeathObserverProxy = data.ReadRemoteObject(); if (kvStoreClientDeathObserverProxy == nullptr) { + ZLOGW("kvStoreClientDeathObserverProxy is nullptr."); return -1; } Status status = RegisterClientDeathObserver(appId, std::move(kvStoreClientDeathObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -634,6 +655,7 @@ int32_t KvStoreDataServiceStub::GetLocalDeviceOnRemote(MessageParcel &data, Mess Status status = GetLocalDevice(info); if (!reply.WriteInt32(static_cast(status)) || !reply.WriteString(info.deviceId) || !reply.WriteString(info.deviceName) || !reply.WriteString(info.deviceType)) { + ZLOGW("write failed."); return -1; } return 0; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp index 72dd7171e..d366654d3 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_resultset.cpp @@ -79,12 +79,13 @@ bool KvStoreResultSetProxy::Move(int offset) } bool ret = data.WriteInt32(offset); if (!ret) { + ZLOGE("write offset failed"); return ret; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(MOVE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d, code=%d", error, MOVE); + ZLOGW("SendRequest returned=%d, code=%d", error, MOVE); return false; } return reply.ReadBool(); @@ -99,12 +100,13 @@ bool KvStoreResultSetProxy::MoveToPosition(int position) } bool ret = data.WriteInt32(position); if (!ret) { + ZLOGE("write position failed"); return ret; } MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(MOVETOPOSITION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d, code=%d", error, MOVETOPOSITION); + ZLOGW("SendRequest returned=%d, code=%d", error, MOVETOPOSITION); return false; } return reply.ReadBool(); @@ -147,13 +149,13 @@ Status KvStoreResultSetProxy::GetEntry(Entry &entry) ZLOGI("start"); int32_t error = Remote()->SendRequest(GETENTRY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } sptr valueTmp = reply.ReadParcelable(); @@ -173,7 +175,7 @@ int KvStoreResultSetProxy::SendRequest(uint32_t code) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(code, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d, code=%d", error, code); + ZLOGW("SendRequest returned=%d, code=%d", error, code); return -1; } return reply.ReadInt32(); @@ -189,7 +191,7 @@ bool KvStoreResultSetProxy::SendRequestRetBool(uint32_t code) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(code, data, reply, mo); if (error != 0) { - ZLOGW("SendRequestRetBool returned %d, code=%d", error, code); + ZLOGW("SendRequestRetBool returned=%d, code=%d", error, code); return false; } return reply.ReadBool(); @@ -317,7 +319,7 @@ int KvStoreResultSetStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me return GetEntryOnRemote(reply); } default: { - ZLOGW("OnRemoteRequest default %d", code); + ZLOGW("OnRemoteRequest default=%d", code); MessageOption mo { MessageOption::TF_SYNC }; return IPCObjectStub::OnRemoteRequest(code, data, reply, mo); } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp index 396b2eae5..522d613f9 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_single.cpp @@ -52,7 +52,7 @@ Status SingleKvStoreProxy::Put(const Key &key, const Value &value) } int error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed with error code %d", error); + ZLOGW("SendRequest failed with error code=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -75,7 +75,7 @@ Status SingleKvStoreProxy::Put(const Key &key, const Value &value) // rawdata: keySize | key | ValueSize | value int32_t error = Remote()->SendRequest(PUT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -96,7 +96,7 @@ Status SingleKvStoreProxy::Delete(const Key &key) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -120,12 +120,12 @@ Status SingleKvStoreProxy::Get(const Key &key, Value &value) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } @@ -165,6 +165,7 @@ Status SingleKvStoreProxy::SubscribeKvStore(const SubscribeType subscribeType, return Status::IPC_ERROR; } if (observer == nullptr) { + ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } if (!data.WriteInt32(static_cast(subscribeType)) || @@ -175,7 +176,7 @@ Status SingleKvStoreProxy::SubscribeKvStore(const SubscribeType subscribeType, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -191,6 +192,7 @@ Status SingleKvStoreProxy::UnSubscribeKvStore(const SubscribeType subscribeType, return Status::IPC_ERROR; } if (observer == nullptr) { + ZLOGE("observer is nullptr"); return Status::INVALID_ARGUMENT; } if (!data.WriteInt32(static_cast(subscribeType)) || @@ -202,7 +204,7 @@ Status SingleKvStoreProxy::UnSubscribeKvStore(const SubscribeType subscribeType, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBEKVSTORE, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -223,12 +225,13 @@ Status SingleKvStoreProxy::GetEntries(const Key &prefixKey, std::vector & MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETENTRIES, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -249,7 +252,7 @@ Status SingleKvStoreProxy::GetEntries(const Key &prefixKey, std::vector & // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, bufferSize); return Status::IPC_ERROR; } @@ -289,12 +292,13 @@ Status SingleKvStoreProxy::GetEntriesWithQuery(const std::string &query, std::ve MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETENTRIESWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -315,7 +319,7 @@ Status SingleKvStoreProxy::GetEntriesWithQuery(const std::string &query, std::ve // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, bufferSize); return Status::IPC_ERROR; } @@ -352,17 +356,19 @@ void SingleKvStoreProxy::GetResultSet(const Key &prefixKey, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETRESULTSET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); callback(Status::IPC_ERROR, nullptr); return; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); callback(status, nullptr); return; } sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject reply failed"); callback(status, nullptr); return; } @@ -388,17 +394,19 @@ void SingleKvStoreProxy::GetResultSetWithQuery(const std::string &query, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETRESULTSETWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); callback(Status::IPC_ERROR, nullptr); return; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); callback(status, nullptr); return; } sptr remote = reply.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject reply failed"); callback(status, nullptr); return; } @@ -423,12 +431,13 @@ Status SingleKvStoreProxy::GetCountWithQuery(const std::string &query, int &resu MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(GETCOUNTWITHQUERY, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { + ZLOGW("ReadInt32 reply failed status=%d", status); return status; } @@ -445,6 +454,7 @@ Status SingleKvStoreProxy::CloseResultSet(sptr resultSetPtr) return Status::IPC_ERROR; } if (resultSetPtr == nullptr) { + ZLOGW("resultSetPtr is nullptr"); return Status::INVALID_ARGUMENT; } @@ -455,7 +465,7 @@ Status SingleKvStoreProxy::CloseResultSet(sptr resultSetPtr) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(CLOSERESULTSET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -486,7 +496,7 @@ Status SingleKvStoreProxy::Sync(const std::vector &deviceIds, SyncM } int32_t error = Remote()->SendRequest(SYNC, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -517,7 +527,7 @@ Status SingleKvStoreProxy::Sync(const std::vector &deviceIds, SyncM MessageParcel reply; int32_t error = Remote()->SendRequest(SYNC_WITH_CONDITION, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %d", error); + ZLOGE("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -539,7 +549,7 @@ Status SingleKvStoreProxy::RemoveDeviceData(const std::string &device) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REMOVEDEVICEDATA, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -565,7 +575,7 @@ Status SingleKvStoreProxy::RegisterSyncCallback(sptr callb MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(REGISTERSYNCCALLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -582,7 +592,7 @@ Status SingleKvStoreProxy::UnRegisterSyncCallback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNREGISTERSYNCCALLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -608,6 +618,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) int64_t bufferSize = 0; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { + ZLOGW("entry length is too long, entry.key=%d, entry.value=%d", item.key.Size(), item.value.Size()); return Status::INVALID_ARGUMENT; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -625,6 +636,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) } MessageOption mo { MessageOption::TF_SYNC }; if (Remote()->SendRequest(PUTBATCH, data, reply, mo) != 0) { + ZLOGW("Remote() SendRequest failed."); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -655,7 +667,7 @@ Status SingleKvStoreProxy::PutBatch(const std::vector &entries) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(PUTBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -689,7 +701,7 @@ Status SingleKvStoreProxy::DeleteBatch(const std::vector &keys) MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(DELETEBATCH, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -705,7 +717,7 @@ Status SingleKvStoreProxy::StartTransaction() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(STARTTRANSACTION, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -721,7 +733,7 @@ Status SingleKvStoreProxy::Commit() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(COMMIT, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -737,7 +749,7 @@ Status SingleKvStoreProxy::Rollback() MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(ROLLBACK, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest returned %d", error); + ZLOGW("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -766,12 +778,12 @@ Status SingleKvStoreProxy::Control(KvControlCmd cmd, const KvParam &inputParam, MessageOption mo{MessageOption::TF_SYNC}; int32_t error = Remote()->SendRequest(CONTROL, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } @@ -882,7 +894,7 @@ Status SingleKvStoreProxy::Subscribe(const std::vector &deviceIds, MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(SUBSCRIBE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %d", error); + ZLOGE("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -912,7 +924,7 @@ Status SingleKvStoreProxy::UnSubscribe(const std::vector &deviceIds MessageOption mo { MessageOption::TF_SYNC }; int32_t error = Remote()->SendRequest(UNSUBSCRIBE, data, reply, mo); if (error != 0) { - ZLOGE("SendRequest returned %d", error); + ZLOGE("SendRequest returned=%d", error); return Status::IPC_ERROR; } return static_cast(reply.ReadInt32()); @@ -967,6 +979,7 @@ int SingleKvStoreStub::PutOnRemote(MessageParcel &data, MessageParcel &reply) } Status status = Put(key, value); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -983,6 +996,7 @@ int SingleKvStoreStub::DeleteOnRemote(MessageParcel &data, MessageParcel &reply) } Status status = Delete(*key); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -1043,6 +1057,7 @@ int SingleKvStoreStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessageParc SubscribeType subscribeType = static_cast(data.ReadInt32()); sptr remote = data.ReadRemoteObject(); if (remote == nullptr) { + ZLOGW("ReadRemoteObject reply failed"); if (!reply.WriteInt32(static_cast(Status::IPC_ERROR))) { return -1; } @@ -1052,6 +1067,7 @@ int SingleKvStoreStub::SubscribeKvStoreOnRemote(MessageParcel &data, MessageParc Status status = SubscribeKvStore(subscribeType, std::move(kvStoreObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -1070,6 +1086,7 @@ int SingleKvStoreStub::UnSubscribeKvStoreOnRemote(MessageParcel &data, MessagePa sptr kvStoreObserverProxy = iface_cast(remote); Status status = UnSubscribeKvStore(subscribeType, std::move(kvStoreObserverProxy)); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status error"); return -1; } return 0; @@ -1118,6 +1135,7 @@ int SingleKvStoreStub::GetEntriesOnRemote(MessageParcel &data, MessageParcel &re std::vector entries; Status status = GetEntries(*keyPrefix, entries); if (status != Status::SUCCESS) { + ZLOGW("write status error"); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1130,7 +1148,7 @@ int SingleKvStoreStub::GetEntriesOnRemote(MessageParcel &data, MessageParcel &re } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -1176,6 +1194,7 @@ int SingleKvStoreStub::GetEntriesWithQueryOnRemote(MessageParcel &data, MessageP std::vector entries; Status status = GetEntriesWithQuery(query, entries); if (status != Status::SUCCESS) { + ZLOGW("write status error"); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1188,7 +1207,7 @@ int SingleKvStoreStub::GetEntriesWithQueryOnRemote(MessageParcel &data, MessageP } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -1229,7 +1248,7 @@ int SingleKvStoreStub::SyncOnRemote(MessageParcel &data, MessageParcel &reply) { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGW("SYNC list:%zu", devices.size()); + ZLOGW("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write sync status fail"); return -1; @@ -1313,7 +1332,7 @@ int SingleKvStoreStub::PutBatchOnRemote(MessageParcel &data, MessageParcel &repl } int len = data.ReadInt32(); if (len < 0) { - ZLOGW("invalid status. len %d", len); + ZLOGW("invalid status. len=%d", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write to parcel failed."); return -1; @@ -1380,7 +1399,7 @@ int SingleKvStoreStub::DeleteBatchOnRemote(MessageParcel &data, MessageParcel &r { int len = data.ReadInt32(); if (len < 0) { - ZLOGW("len %d invalid after ipc", len); + ZLOGW("len=%d invalid after ipc", len); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGW("write delete failed."); return -1; @@ -1447,7 +1466,7 @@ int SingleKvStoreStub::OnSecurityLevelRequest(MessageParcel &data, MessageParcel SecurityLevel securityLevel = SecurityLevel::NO_LABEL; auto status = GetSecurityLevel(securityLevel); if (!reply.WriteInt32(static_cast(status))) { - ZLOGW("Get SecurityLevel ipc failed."); + ZLOGW("Get SecurityLevel ipc error."); return -1; } if (!reply.WriteInt32(static_cast(securityLevel))) { @@ -1485,6 +1504,7 @@ int SingleKvStoreStub::GetCountWithQueryOnRemote(MessageParcel &data, MessagePar int result; Status status = GetCountWithQuery(query, result); if (status != Status::SUCCESS) { + ZLOGW("get status failed."); if (!reply.WriteInt32(static_cast(status))) { return -1; } @@ -1501,6 +1521,7 @@ int SingleKvStoreStub::CloseResultSetOnRemote(MessageParcel &data, MessageParcel { sptr obj = data.ReadRemoteObject(); if (obj == nullptr) { + ZLOGW("ReadRemoteObject failed."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { return -1; } @@ -1509,6 +1530,7 @@ int SingleKvStoreStub::CloseResultSetOnRemote(MessageParcel &data, MessageParcel sptr kvStoreResultSetProxy = iface_cast(obj); Status status = CloseResultSet(kvStoreResultSetProxy); if (!reply.WriteInt32(static_cast(status))) { + ZLOGW("write status failed."); return -1; } return 0; @@ -1605,7 +1627,7 @@ int SingleKvStoreStub::OnSyncRequest(MessageParcel &data, MessageParcel &reply) { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGI("SYNC list:%zu", devices.size()); + ZLOGI("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; @@ -1645,7 +1667,7 @@ int SingleKvStoreStub::OnSubscribeRequest(MessageParcel &data, MessageParcel &re { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGE("SYNC list:%zu", devices.size()); + ZLOGE("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; @@ -1666,7 +1688,7 @@ int SingleKvStoreStub::OnUnSubscribeRequest(MessageParcel &data, MessageParcel & { std::vector devices; if (!data.ReadStringVector(&devices) || devices.empty()) { - ZLOGE("SYNC list:%zu", devices.size()); + ZLOGE("SYNC list=%zu", devices.size()); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { ZLOGE("write sync status fail"); return -1; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp index 9674351eb..93f25b730 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/ikvstore_snapshot.cpp @@ -72,7 +72,7 @@ void KvStoreSnapshotImplProxy::GetEntries(const Key &prefixKey, const Key &nextK Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success, which is %d", static_cast(status)); + ZLOGW("status not success, which = %d", static_cast(status)); callback(status, entries, Key()); return; } @@ -94,7 +94,7 @@ void KvStoreSnapshotImplProxy::GetEntries(const Key &prefixKey, const Key &nextK // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyEntryCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyEntryCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyEntryCount, + ZLOGW("replyEntryCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyEntryCount, bufferSize); callback(Status::IPC_ERROR, entries, Key()); return; @@ -128,14 +128,17 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, } std::vector keyList; if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGW("SetMaxCapacity failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } if (!data.WriteParcelable(&prefixKey)) { + ZLOGW("prefixKey WriteParcelable failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } if (!data.WriteParcelable(&nextKey)) { + ZLOGW("nextKey WriteParcelable failed"); callback(Status::IPC_ERROR, keyList, Key()); return; } @@ -149,7 +152,7 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success, which is %d", static_cast(status)); + ZLOGW("status not successful, error = %d", static_cast(status)); callback(status, keyList, Key()); return; } @@ -171,7 +174,7 @@ void KvStoreSnapshotImplProxy::GetKeys(const Key &prefixKey, const Key &nextKey, // this memory is managed by MassageParcel, DO NOT free here const uint8_t *buffer = reinterpret_cast(reply.ReadRawData(bufferSize)); if (replyKeyCount < 0 || bufferSize < 0 || buffer == nullptr) { - ZLOGW("replyKeyCount(%d) or bufferSize(%d) less than 0, or buffer is nullptr", replyKeyCount, bufferSize); + ZLOGW("replyKeyCount=%d or bufferSize=%d less than 0, or buffer is nullptr", replyKeyCount, bufferSize); callback(Status::IPC_ERROR, keyList, Key()); return; } @@ -201,9 +204,11 @@ Status KvStoreSnapshotImplProxy::Get(const Key &key, Value &value) return Status::IPC_ERROR; } if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGW("SetMaxCapacity failed"); return Status::IPC_ERROR; } if (!data.WriteParcelable(&key)) { + ZLOGW("key WriteParcelable failed"); return Status::IPC_ERROR; } @@ -211,12 +216,12 @@ Status KvStoreSnapshotImplProxy::Get(const Key &key, Value &value) ZLOGI("start"); int32_t error = Remote()->SendRequest(GET, data, reply, mo); if (error != 0) { - ZLOGW("SendRequest failed, error is %d", error); + ZLOGW("SendRequest failed, error = %d", error); return Status::IPC_ERROR; } Status status = static_cast(reply.ReadInt32()); if (status != Status::SUCCESS) { - ZLOGW("status not success(%d)", static_cast(status)); + ZLOGW("status not successful, error=%d", static_cast(status)); return status; } @@ -334,7 +339,7 @@ int32_t KvStoreSnapshotImplStub::GetEntriesOnRemote(MessageParcel &data, Message } ZLOGI("getting large entry set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR))) { return -1; } @@ -382,6 +387,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce if (keyPrefix == nullptr) { ZLOGW("keyPrefix is null"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("keyPrefix WriteInt32 error"); return -1; } if (!reply.WriteParcelable(nullptr)) { @@ -392,6 +398,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce if (nextKey == nullptr) { ZLOGW("nextKey is null. return."); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("nextKey WriteInt32 error"); return -1; } if (!reply.WriteParcelable(nullptr)) { @@ -413,7 +420,7 @@ int32_t KvStoreSnapshotImplStub::GetKeysRemote(MessageParcel &data, MessageParce } ZLOGI("getting large key set"); if (bufferSize > static_cast(reply.GetRawDataCapacity())) { - ZLOGW("bufferSize %d larger than message parcel limit", bufferSize); + ZLOGW("bufferSize=%d larger than message parcel limit", bufferSize); if (!reply.WriteInt32(static_cast(Status::ERROR)) || !reply.WriteParcelable(&nxtKey)) { ZLOGW("write status failed."); @@ -460,6 +467,7 @@ int32_t KvStoreSnapshotImplStub::GetRemote(MessageParcel &data, MessageParcel &r if (key == nullptr) { ZLOGW("key is null"); if (!reply.WriteInt32(static_cast(Status::INVALID_ARGUMENT))) { + ZLOGW("key WriteInt32 is null"); return -1; } if (!reply.WriteInt32(0)) { @@ -519,6 +527,7 @@ int32_t KvStoreSnapshotImplStub::OnRemoteRequest(uint32_t code, MessageParcel &d return -1; } if (!reply.SetMaxCapacity(Constant::MAX_IPC_CAPACITY)) { + ZLOGW("reply SetMaxCapacity failed."); return -1; } switch (code) { @@ -533,6 +542,7 @@ int32_t KvStoreSnapshotImplStub::OnRemoteRequest(uint32_t code, MessageParcel &d } default: if (!reply.WriteInt32((int32_t)Status::ERROR)) { + ZLOGW("reply WriteInt32 status failed."); return -1; } return 0; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp index 2f084d300..d0227968a 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/itypes_util.cpp @@ -57,6 +57,7 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, std::vector &output) bool ITypesUtil::Marshalling(const Entry &entry, MessageParcel &data) { if (!Marshalling(entry.key, data)) { + ZLOGW("Marshalling failed"); return false; } return Marshalling(entry.value, data); @@ -65,6 +66,7 @@ bool ITypesUtil::Marshalling(const Entry &entry, MessageParcel &data) bool ITypesUtil::Unmarshalling(MessageParcel &data, Entry &output) { if (!Unmarshalling(data, output.key)) { + ZLOGW("Unmarshalling failed"); return false; } return Unmarshalling(data, output.value); @@ -73,9 +75,11 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, Entry &output) bool ITypesUtil::Marshalling(const DeviceInfo &entry, MessageParcel &data) { if (!data.WriteString(entry.deviceId)) { + ZLOGW("write deviceId failed"); return false; } if (!data.WriteString(entry.deviceName)) { + ZLOGW("write deviceName failed"); return false; } return data.WriteString(entry.deviceType); @@ -84,9 +88,11 @@ bool ITypesUtil::Marshalling(const DeviceInfo &entry, MessageParcel &data) bool ITypesUtil::Unmarshalling(MessageParcel &data, DeviceInfo &output) { if (!data.ReadString(output.deviceId)) { + ZLOGW("read deviceId failed"); return false; } if (!data.ReadString(output.deviceName)) { + ZLOGW("read deviceName failed"); return false; } return data.ReadString(output.deviceType); @@ -104,14 +110,17 @@ bool ITypesUtil::Unmarshalling(MessageParcel &data, std::vector &out bool ITypesUtil::Marshalling(const ChangeNotification ¬ification, MessageParcel &parcel) { if (!Marshalling(notification.GetInsertEntries(), parcel)) { + ZLOGW("GetInsertEntries failed"); return false; } if (!Marshalling(notification.GetUpdateEntries(), parcel)) { + ZLOGW("GetUpdateEntries failed"); return false; } if (!Marshalling(notification.GetDeleteEntries(), parcel)) { + ZLOGW("GetDeleteEntries failed"); return false; } if (!parcel.WriteString(notification.GetDeviceId())) { @@ -126,14 +135,17 @@ bool ITypesUtil::Unmarshalling(MessageParcel &parcel, ChangeNotification &output { std::vector insertEntries; if (!Unmarshalling(parcel, insertEntries)) { + ZLOGW("insertEntries failed"); return false; } std::vector updateEntries; if (!Unmarshalling(parcel, updateEntries)) { + ZLOGW("updateEntries failed"); return false; } std::vector deleteEntries; if (!Unmarshalling(parcel, deleteEntries)) { + ZLOGW("deleteEntries failed"); return false; } std::string deviceId; @@ -368,6 +380,7 @@ int64_t ITypesUtil::GetTotalSize(const std::vector &entries) int64_t bufferSize = 1; for (const auto &item : entries) { if (item.key.Size() > Constant::MAX_KEY_LENGTH || item.value.Size() > Constant::MAX_VALUE_LENGTH) { + ZLOGW("entry length too long key=%d, value=%d", item.key.Size(), item.value.Size()); return -bufferSize; } bufferSize += item.key.RawSize() + item.value.RawSize(); @@ -379,6 +392,7 @@ int64_t ITypesUtil::GetTotalSize(const std::vector &entries) int64_t bufferSize = 1; for (const auto &item : entries) { if (item.Size() > Constant::MAX_KEY_LENGTH) { + ZLOGW("entry length too long, size=%d", item.Size()); return -bufferSize; } bufferSize += item.RawSize(); @@ -391,21 +405,25 @@ bool ITypesUtil::ReadVector(Parcel &parcel, std::vector &val, bool (Parcel::* { int32_t len = parcel.ReadInt32(); if (len < 0) { + ZLOGW("read parcel error len=%d", len); return false; } size_t readAbleSize = parcel.GetReadableBytes(); size_t size = static_cast(len); if ((size > readAbleSize) || (size > val.max_size())) { + ZLOGW("parcel size too long, size=%d", size); return false; } val.resize(size); if (val.size() < size) { + ZLOGW("size too long, size=%d", size); return false; } for (auto &v : val) { if (!(parcel.*read)(v)) { + ZLOGW("parcel read value error"); return false; } } @@ -417,15 +435,18 @@ template bool ITypesUtil::WriteVector(Parcel &parcel, const std::vector &val, bool (Parcel::*writer)(const T &)) { if (val.size() > INT_MAX) { + ZLOGW("value size too long, size=%d", val.size()); return false; } if (!parcel.WriteInt32(static_cast(val.size()))) { + ZLOGW("parcel write size error"); return false; } for (auto &v : val) { if (!(parcel.*writer)(v)) { + ZLOGW("parcel write value error"); return false; } } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp index 00192e53c..3840e8cbe 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_client.cpp @@ -63,7 +63,7 @@ Status KvStoreClient::GetKvStoreSnapshot(std::shared_ptr observ }; kvStoreProxy_->GetKvStoreSnapshot(kvStoreObserverClient, snapshotCallbackFunction); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error: %d.", static_cast(statusTmp)); + ZLOGE("return error=%d.", static_cast(statusTmp)); return statusTmp; } @@ -95,13 +95,13 @@ Status KvStoreClient::ReleaseKvStoreSnapshot(std::shared_ptr &s sptr snapshotProxyTmp = kvStoreSnapshotClient->GetkvStoreSnapshotProxy(); Status status = kvStoreProxy_->ReleaseKvStoreSnapshot(std::move(snapshotProxyTmp)); snapshot = nullptr; - ZLOGI("return: %d.", static_cast(status)); + ZLOGI("return=%d.", static_cast(status)); return status; } Status KvStoreClient::Put(const Key &key, const Value &value) { - ZLOGD("key: %zu value: %zu.", key.Size(), value.Size()); + ZLOGD("key=%zu value=%zu.", key.Size(), value.Size()); DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); std::vector keyData = Constant::TrimCopy>(key.Data()); @@ -120,7 +120,7 @@ Status KvStoreClient::Put(const Key &key, const Value &value) Status KvStoreClient::PutBatch(const std::vector &entries) { - ZLOGI("entry size: %zu", entries.size()); + ZLOGI("entry size=%zu", entries.size()); DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); if (entries.size() > Constant::MAX_BATCH_SIZE) { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp index 61c4707aa..25a7a3a69 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_resultset_client.cpp @@ -17,11 +17,14 @@ #include "kvstore_resultset_client.h" #include "dds_trace.h" +#include "log_print.h" namespace OHOS::DistributedKv { KvStoreResultSetClient::KvStoreResultSetClient(sptr kvStoreProxy) :kvStoreResultSetProxy_(kvStoreProxy) -{} +{ + ZLOGI("constructor"); +} int KvStoreResultSetClient::GetCount() const { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp index c0f239c76..4a51ee120 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_service_death_notifier.cpp @@ -80,6 +80,7 @@ sptr KvStoreServiceDeathNotifier::GetDistributedKvDataServi void KvStoreServiceDeathNotifier::RegisterClientDeathObserver() { if (kvDataServiceProxy_ == nullptr) { + ZLOGE("initialize proxy failed."); return; } if (clientDeathObserverPtr_ == nullptr) { @@ -97,9 +98,9 @@ void KvStoreServiceDeathNotifier::AddServiceDeathWatcher(std::shared_ptr lg(watchMutex_); auto ret = serviceDeathWatchers_.insert(watcher); if (ret.second) { - ZLOGI("success set size: %zu", serviceDeathWatchers_.size()); + ZLOGI("success set size=%zu", serviceDeathWatchers_.size()); } else { - ZLOGE("failed set size: %zu", serviceDeathWatchers_.size()); + ZLOGE("failed set size=%zu", serviceDeathWatchers_.size()); } } @@ -109,9 +110,9 @@ void KvStoreServiceDeathNotifier::RemoveServiceDeathWatcher(std::shared_ptr lg(watchMutex_); kvDataServiceProxy_ = nullptr; - ZLOGI("watcher set size: %zu", serviceDeathWatchers_.size()); + ZLOGI("watcher set size=%zu", serviceDeathWatchers_.size()); for (const auto &watcher : serviceDeathWatchers_) { std::thread th = std::thread([watcher]() { watcher->OnRemoteDied(); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp index b20d66156..ce9b7448b 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_snapshot_client.cpp @@ -84,6 +84,7 @@ Status KvStoreSnapshotClient::GetEntries(const Key &prefixKey, std::vector &en [&status, &entries, &startKey](Status stat, auto &result, Key next) { status = stat; if (stat != Status::SUCCESS) { + ZLOGE("status error=%d.", status); return; } startKey = result.empty() ? "" : next; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp index 47387a8c8..df63e6c29 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp @@ -28,10 +28,13 @@ namespace OHOS::DistributedKv { SingleKvStoreClient::SingleKvStoreClient(sptr kvStoreProxy, const std::string &storeId) : kvStoreProxy_(kvStoreProxy), storeId_(storeId), syncCallbackClient_(new KvStoreSyncCallbackClient()), syncObserver_(std::make_shared()) -{} +{ + ZLOGI("constructor."); +} SingleKvStoreClient::~SingleKvStoreClient() { + ZLOGI("destructor."); kvStoreProxy_->UnRegisterSyncCallback(); syncObserver_->Clean(); } @@ -88,7 +91,7 @@ Status SingleKvStoreClient::GetResultSet(const Key &prefixKey, std::shared_ptrGetResultSet(prefixKey, callFun); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error: %d.", static_cast(statusTmp)); + ZLOGE("return error=%d.", static_cast(statusTmp)); return statusTmp; } @@ -120,7 +123,7 @@ Status SingleKvStoreClient::GetResultSetWithQuery(const std::string &query, }; kvStoreProxy_->GetResultSetWithQuery(query, callFun); if (statusTmp != Status::SUCCESS) { - ZLOGE("return error: %d.", static_cast(statusTmp)); + ZLOGE("return error=%d.", static_cast(statusTmp)); return statusTmp; } @@ -226,7 +229,7 @@ Status SingleKvStoreClient::Put(const Key &key, const Value &value) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); - ZLOGI("key: %zu value: %zu.", key.Size(), value.Size()); + ZLOGI("key=%zu value=%zu.", key.Size(), value.Size()); std::vector keyData = Constant::TrimCopy>(key.Data()); if (keyData.size() == 0 || keyData.size() > Constant::MAX_KEY_LENGTH || value.Size() > Constant::MAX_VALUE_LENGTH) { @@ -348,7 +351,7 @@ Status SingleKvStoreClient::PutBatch(const std::vector &entries) { DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true); - ZLOGI("entry size: %zu", entries.size()); + ZLOGI("entry size=%zu", entries.size()); if (entries.size() > Constant::MAX_BATCH_SIZE) { ZLOGE("batch size must less than 128."); return Status::INVALID_ARGUMENT; @@ -422,12 +425,14 @@ Status SingleKvStoreClient::GetSyncParam(KvSyncParam &syncParam) KvParam output; Status ret = Control(KvControlCmd::GET_SYNC_PARAM, inputEmpty, output); if (ret != Status::SUCCESS) { + ZLOGE("ret error=%d.", ret); return ret; } if (output.Size() == sizeof(uint32_t)) { syncParam.allowedDelayMs = TransferByteArrayToType(output.Data()); return Status::SUCCESS; } + ZLOGE("output size error."); return Status::ERROR; } diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp index 1be079979..a1a9c76cf 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_manager_impl.cpp @@ -43,7 +43,7 @@ static sptr GetDistributedDataManager() std::this_thread::sleep_for(std::chrono::seconds(RdbManagerImpl::RETRY_INTERVAL)); continue; } - ZLOGI("get distributed data manager success"); + ZLOGI("get distributed data manager successful"); return iface_cast(remoteObject); } @@ -59,7 +59,7 @@ static void LinkToDeath(const sptr& remote) if (!remote->AddDeathRecipient(deathRecipient)) { ZLOGE("add death recipient failed"); } - ZLOGE("success"); + ZLOGE("successful"); } RdbManagerImpl::RdbManagerImpl() @@ -104,6 +104,7 @@ std::shared_ptr RdbManagerImpl::GetRdbService(const RdbSyncerParam& } auto service = GetRdbService(); if (service == nullptr) { + ZLOGE("get rdb service is nullptr"); return nullptr; } if (((RdbServiceProxy *)service.GetRefPtr())->InitNotifier(param) != RDB_OK) { @@ -128,10 +129,12 @@ void RdbManagerImpl::OnRemoteDied() param.bundleName_ = bundleName_; auto service = GetRdbService(param); if (service == nullptr) { + ZLOGI("rdb service alreadly dead"); return; } proxy = std::static_pointer_cast(service); if (proxy == nullptr) { + ZLOGI("rdb service proxy alreadly dead"); return; } ZLOGI("restore observer"); diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp index dba5a48a5..072ac16e4 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_notifier.cpp @@ -44,6 +44,7 @@ int32_t RdbNotifierProxy::OnComplete(uint32_t seqNum, const SyncResult &result) return RDB_ERROR; } if (!DistributedKv::ITypesUtil::Marshalling(result, data)) { + ZLOGE("marshalling result and data failed"); return RDB_ERROR; } @@ -109,6 +110,7 @@ int RdbNotifierStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message { ZLOGI("code=%{public}u", code); if (!CheckInterfaceToken(data)) { + ZLOGE("CheckInterfaceToken data error."); return RDB_ERROR; } diff --git a/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp b/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp index 899882932..009be07fd 100644 --- a/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp +++ b/frameworks/innerkitsimpl/rdb/src/rdb_service_proxy.cpp @@ -36,7 +36,7 @@ void RdbServiceProxy::OnSyncComplete(uint32_t seqNum, const SyncResult &result) void RdbServiceProxy::OnDataChange(const std::string& storeName, const std::vector &devices) { - ZLOGI("%{public}s", storeName.c_str()); + ZLOGI("storeName=%{public}s", storeName.c_str()); observers_.ComputeIfPresent( storeName, [&devices] (const auto& key, const ObserverMapValue& value) { for (const auto& observer : value.first) { @@ -90,7 +90,7 @@ int32_t RdbServiceProxy::InitNotifier(const RdbSyncerParam& param) return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); return RDB_OK; } @@ -165,10 +165,10 @@ int32_t RdbServiceProxy::DoSync(const RdbSyncerParam& param, const SyncOption &o { SyncResult result; if (DoSync(param, option, predicates, result) != RDB_OK) { - ZLOGI("failed"); + ZLOGE("dosync failed"); return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); if (callback != nullptr) { callback(result); @@ -222,12 +222,12 @@ int32_t RdbServiceProxy::DoAsync(const RdbSyncerParam& param, const SyncOption & ZLOGI("num=%{public}u", num); if (DoAsync(param, num, option, predicates) != RDB_OK) { - ZLOGE("failed"); + ZLOGE("do async failed"); syncCallbacks_.Erase(num); return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); return RDB_OK; } @@ -262,6 +262,7 @@ int32_t RdbServiceProxy::Sync(const RdbSyncerParam& param, const SyncOption &opt const RdbPredicates &predicates, const SyncCallback &callback) { if (option.isBlock) { + ZLOGI("option isBlock"); return DoSync(param, option, predicates, callback); } return DoAsync(param, option, predicates, callback); @@ -275,7 +276,7 @@ int32_t RdbServiceProxy::Subscribe(const RdbSyncerParam ¶m, const SubscribeO return RDB_ERROR; } if (DoSubscribe(param) != RDB_OK) { - ZLOGI("communicate to server failed"); + ZLOGE("communicate to server failed"); return RDB_ERROR; } observers_.Compute( diff --git a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp index d3f105d41..8d922e98c 100644 --- a/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/entry_point.cpp @@ -29,19 +29,19 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("createKVManager", JsKVManager::CreateKVManager) }; napi_status status = napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - ZLOGI("init createKVManager %{public}d", status); + ZLOGI("init createKVManager status=%{public}d", status); status = napi_set_named_property(env, exports, "FieldNode", JsFieldNode::Constructor(env)); - ZLOGI("init FieldNode %{public}d", status); + ZLOGI("init FieldNode status=%{public}d", status); status = napi_set_named_property(env, exports, "Schema", JsSchema::Constructor(env)); - ZLOGI("init Schema %{public}d", status); + ZLOGI("init Schema status=%{public}d", status); status = napi_set_named_property(env, exports, "Query", JsQuery::Constructor(env)); - ZLOGI("init Query %{public}d", status); + ZLOGI("init Query status=%{public}d", status); status = InitConstProperties(env, exports); - ZLOGI("init Enumerate Constants %{public}d", status); + ZLOGI("init Enumerate Constants status=%{public}d", status); return exports; } diff --git a/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp index 7034d5883..ae7f74928 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_device_kv_store.cpp @@ -38,10 +38,12 @@ static std::string GetDeviceKey(const std::string& deviceId, const std::string& JsDeviceKVStore::JsDeviceKVStore(const std::string& storeId) : JsKVStore(storeId) { + ZLOGD("constructor"); } napi_value JsDeviceKVStore::Constructor(napi_env env) { + ZLOGD("JsDeviceKVStore::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("put", JsKVStore::Put), DECLARE_NAPI_FUNCTION("delete", JsKVStore::Delete), @@ -100,7 +102,7 @@ napi_value JsDeviceKVStore::Get(napi_env env, napi_callback_info info) OHOS::DistributedKv::Value value; auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Get(deviceKey, value); - ZLOGD("kvStore->Get return %{public}d", status); + ZLOGD("kvStore->Get return status=%{public}d", status); ctxt->value = JSUtil::Blob2VariantValue(value); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Get() failed!"); @@ -192,16 +194,16 @@ napi_value JsDeviceKVStore::GetEntries(napi_env env, napi_callback_info info) std::string deviceKey = GetDeviceKey(ctxt->va.deviceId, ctxt->va.keyPrefix); OHOS::DistributedKv::Key keyPrefix(deviceKey); status = kvStore->GetEntries(keyPrefix, ctxt->entries); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::DEVICEID_QUERY) { auto query = ctxt->va.query->GetNative(); query.DeviceId(ctxt->va.deviceId); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetEntries() failed!"); @@ -250,16 +252,16 @@ napi_value JsDeviceKVStore::GetResultSet(napi_env env, napi_callback_info info) std::string deviceKey = GetDeviceKey(ctxt->va.deviceId, ctxt->va.keyPrefix); OHOS::DistributedKv::Key keyPrefix(deviceKey); status = kvStore->GetResultSet(keyPrefix, kvResultSet); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::DEVICEID_QUERY) { auto query = ctxt->va.query->GetNative(); query.DeviceId(ctxt->va.deviceId); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetResultSet() failed!"); @@ -300,7 +302,7 @@ napi_value JsDeviceKVStore::CloseResultSet(napi_env env, napi_callback_info info auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->CloseResultSet(ctxt->resultSet->GetNative()); - ZLOGD("kvStore->CloseResultSet return %{public}d", status); + ZLOGD("kvStore->CloseResultSet return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->CloseResultSet failed!"); }; @@ -338,7 +340,7 @@ napi_value JsDeviceKVStore::GetResultSize(napi_env env, napi_callback_info info) query.DeviceId(ctxt->va.deviceId); } Status status = kvStore->GetCountWithQuery(query.ToString(), ctxt->resultSize); - ZLOGD("kvStore->GetCountWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetCountWithQuery() return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetCountWithQuery() failed!"); }; @@ -372,7 +374,7 @@ napi_value JsDeviceKVStore::RemoveDeviceData(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->RemoveDeviceData(ctxt->deviceId); - ZLOGD("kvStore->RemoveDeviceData return %{public}d", status); + ZLOGD("kvStore->RemoveDeviceData return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->RemoveDeviceData() failed!"); }; @@ -385,6 +387,7 @@ napi_value JsDeviceKVStore::RemoveDeviceData(napi_env env, napi_callback_info in */ napi_value JsDeviceKVStore::Sync(napi_env env, napi_callback_info info) { + ZLOGD("JsDeviceKVStore::Sync"); struct SyncContext : public ContextBase { std::vector deviceIdList; uint32_t mode = 0; @@ -404,7 +407,7 @@ napi_value JsDeviceKVStore::Sync(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Sync(ctxt->deviceIdList, static_cast(ctxt->mode)); - ZLOGD("kvStore->Sync return %{public}d!", status); + ZLOGD("kvStore->Sync return status=%{public}d!", status); NAPI_ASSERT(env, status == Status::SUCCESS, "kvStore->Sync() failed!"); return nullptr; } diff --git a/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp b/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp index c18072280..d44e90c37 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_field_node.cpp @@ -41,6 +41,7 @@ std::map JsFieldNode::valueTypeToString_ = { JsFieldNode::JsFieldNode(const std::string& fName) : fieldName(fName) { + ZLOGD("constructor"); } std::string JsFieldNode::GetFieldName() @@ -63,6 +64,7 @@ JsFieldNode::json JsFieldNode::GetValueForJson() napi_value JsFieldNode::Constructor(napi_env env) { + ZLOGD("JsFieldNode::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("appendChild", JsFieldNode::AppendChild), DECLARE_NAPI_GETTER_SETTER("default", JsFieldNode::GetDefaultValue, JsFieldNode::SetDefaultValue), @@ -251,6 +253,7 @@ std::string JsFieldNode::ValueTypeToString(uint32_t type) // DistributedDB::FieldType auto it = valueTypeToString_.find(type); if (valueTypeToString_.find(type) != valueTypeToString_.end()) { + ZLOGD("find type is the last"); return it->second; } else { return std::string(); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp index 8759ac81d..2966ee05c 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_manager.cpp @@ -126,7 +126,7 @@ napi_value JsKVManager::GetKVStore(napi_env env, napi_callback_info info) StoreId storeId = { ctxt->storeId }; std::shared_ptr kvStore; Status status = kvm->kvDataManager_.GetSingleKvStore(ctxt->options, appId, storeId, kvStore); - ZLOGD("GetSingleKvStore return status:%{public}d", status); + ZLOGD("GetSingleKvStore return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "KVManager->GetSingleKvStore() failed!"); ctxt->kvStore->SetNative(kvStore); @@ -172,7 +172,7 @@ napi_value JsKVManager::CloseKVStore(napi_env env, napi_callback_info info) AppId appId { ctxt->appId }; StoreId storeId { ctxt->storeId }; Status status = reinterpret_cast(ctxt->native)->kvDataManager_.CloseKvStore(appId, storeId); - ZLOGD("CloseKVStore return status:%{public}d", status); + ZLOGD("CloseKVStore return status=%{public}d", status); ctxt->status = ((status == Status::SUCCESS) || (status == Status::STORE_NOT_FOUND) || (status == Status::STORE_NOT_OPEN)) ? napi_ok @@ -209,7 +209,7 @@ napi_value JsKVManager::DeleteKVStore(napi_env env, napi_callback_info info) AppId appId { ctxt->appId }; StoreId storeId { ctxt->storeId }; Status status = reinterpret_cast(ctxt->native)->kvDataManager_.DeleteKvStore(appId, storeId); - ZLOGD("DeleteKvStore status:%{public}d", status); + ZLOGD("DeleteKvStore status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; }; return NapiQueue::AsyncWork(env, ctxt, std::string(__FUNCTION__), execute); @@ -242,25 +242,26 @@ napi_value JsKVManager::GetAllKVStoreId(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, kvm != nullptr, "KVManager is null, failed!"); AppId appId { ctxt->appId }; Status status = kvm->kvDataManager_.GetAllKvStoreId(appId, ctxt->storeIdList); - ZLOGD("execute status:%{public}d", status); + ZLOGD("execute status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; }; auto output = [env, ctxt](napi_value& result) { ctxt->status = JSUtil::SetValue(env, ctxt->storeIdList, result); - ZLOGD("output status:%{public}d", ctxt->status); + ZLOGD("output status=%{public}d", ctxt->status); }; return NapiQueue::AsyncWork(env, ctxt, std::string(__FUNCTION__), execute, output); } napi_value JsKVManager::On(napi_env env, napi_callback_info info) { + ZLOGD("KVManager::On()"); auto ctxt = std::make_shared(); auto input = [env, ctxt](size_t argc, napi_value* argv) { // required 2 arguments :: CHECK_ARGS_RETURN_VOID(ctxt, argc == 2, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("subscribe to event:%{public}s", event.c_str()); + ZLOGI("subscribe to event=%{public}s", event.c_str()); CHECK_ARGS_RETURN_VOID(ctxt, event == "distributedDataServiceDie", "invalid arg[0], i.e. invalid event!"); napi_valuetype valueType = napi_undefined; @@ -298,7 +299,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); // required 1 arguments :: - ZLOGI("unsubscribe to event:%{public}s %{public}s specified", event.c_str(), (argc == 1) ? "without": "with"); + ZLOGI("unsubscribe to event=%{public}s %{public}s specified", event.c_str(), (argc == 1) ? "without": "with"); CHECK_ARGS_RETURN_VOID(ctxt, event == "distributedDataServiceDie", "invalid arg[0], i.e. invalid event!"); // have 2 arguments :: have the [callback] if (argc == 2) { @@ -320,7 +321,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) ++it; } } - ZLOGD("off mapsize: %{public}d", static_cast(proxy->deathRecipient_.size())); + ZLOGD("off mapsize=%{public}d", static_cast(proxy->deathRecipient_.size())); }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -330,6 +331,7 @@ napi_value JsKVManager::Off(napi_env env, napi_callback_info info) napi_value JsKVManager::Constructor(napi_env env) { + ZLOGD("KVManager::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("getKVStore", JsKVManager::GetKVStore), DECLARE_NAPI_FUNCTION("closeKVStore", JsKVManager::CloseKVStore), @@ -344,6 +346,7 @@ napi_value JsKVManager::Constructor(napi_env env) napi_value JsKVManager::New(napi_env env, napi_callback_info info) { + ZLOGD("KVManager::New"); std::string bundleName; auto ctxt = std::make_shared(); auto input = [env, ctxt, &bundleName](size_t argc, napi_value* argv) { @@ -356,7 +359,7 @@ napi_value JsKVManager::New(napi_env env, napi_callback_info info) ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - JsKVManager* kvManager = new (std::nothrow) JsKVManager(bundleName, env); + JsKVManager* kvManager = new (std::nothrow) JsKVManager(bundleName); NAPI_ASSERT(env, kvManager !=nullptr, "no memory for kvManager"); auto finalize = [](napi_env env, void* data, void* hint) { diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp index b82ae3aa7..7af0213f8 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_store.cpp @@ -182,7 +182,7 @@ napi_value JsKVStore::OnEvent(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, argc >= 2, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("subscribe to event:%{public}s", event.c_str()); + ZLOGI("subscribe to event=%{public}s", event.c_str()); auto handle = onEventHandlers_.find(event); CHECK_ARGS_RETURN_VOID(ctxt, handle != onEventHandlers_.end(), "invalid arg[0], i.e. unsupported event"); // shift 1 argument, for JsKVStore::Exec. @@ -208,7 +208,7 @@ napi_value JsKVStore::OffEvent(napi_env env, napi_callback_info info) CHECK_ARGS_RETURN_VOID(ctxt, argc >= 1, "invalid arguments!"); std::string event; ctxt->status = JSUtil::GetValue(env, argv[0], event); - ZLOGI("unsubscribe to event:%{public}s", event.c_str()); + ZLOGI("unsubscribe to event=%{public}s", event.c_str()); auto handle = offEventHandlers_.find(event); CHECK_ARGS_RETURN_VOID(ctxt, handle != offEventHandlers_.end(), "invalid arg[0], i.e. unsupported event"); // shift 1 argument, for JsKVStore::Exec. @@ -228,6 +228,7 @@ napi_value JsKVStore::OffEvent(napi_env env, napi_callback_info info) */ napi_value JsKVStore::PutBatch(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct PutBatchContext : public ContextBase { std::vector entries; }; @@ -259,6 +260,7 @@ napi_value JsKVStore::PutBatch(napi_env env, napi_callback_info info) */ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct DeleteBatchContext : public ContextBase { std::vector keys; }; @@ -279,7 +281,7 @@ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) } auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->DeleteBatch(keys); - ZLOGD("kvStore->DeleteBatch return %{public}d", status); + ZLOGD("kvStore->DeleteBatch return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->DeleteBatch failed!"); }; @@ -295,13 +297,14 @@ napi_value JsKVStore::DeleteBatch(napi_env env, napi_callback_info info) */ napi_value JsKVStore::StartTransaction(napi_env env, napi_callback_info info) { + ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->StartTransaction(); - ZLOGD("kvStore->StartTransaction return %{public}d", status); + ZLOGD("kvStore->StartTransaction return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->StartTransaction() failed!"); }; @@ -317,13 +320,14 @@ napi_value JsKVStore::StartTransaction(napi_env env, napi_callback_info info) */ napi_value JsKVStore::Commit(napi_env env, napi_callback_info info) { + ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->Commit(); - ZLOGD("kvStore->Commit return %{public}d", status); + ZLOGD("kvStore->Commit return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Commit() failed!"); }; @@ -339,13 +343,14 @@ napi_value JsKVStore::Commit(napi_env env, napi_callback_info info) */ napi_value JsKVStore::Rollback(napi_env env, napi_callback_info info) { + ZLOGD("in"); auto ctxt = std::make_shared(); ctxt->GetCbInfo(env, info); auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->Rollback(); - ZLOGD("kvStore->Commit return %{public}d", status); + ZLOGD("kvStore->Commit return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->Rollback() failed!"); }; @@ -361,6 +366,7 @@ napi_value JsKVStore::Rollback(napi_env env, napi_callback_info info) */ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct EnableSyncContext : public ContextBase { bool enable = false; }; @@ -376,7 +382,7 @@ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->SetCapabilityEnabled(ctxt->enable); - ZLOGD("kvStore->SetCapabilityEnabled return %{public}d", status); + ZLOGD("kvStore->SetCapabilityEnabled return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->SetCapabilityEnabled() failed!"); }; @@ -392,6 +398,7 @@ napi_value JsKVStore::EnableSync(napi_env env, napi_callback_info info) */ napi_value JsKVStore::SetSyncRange(napi_env env, napi_callback_info info) { + ZLOGD("in"); struct SyncRangeContext : public ContextBase { std::vector localLabels; std::vector remoteSupportLabels; @@ -410,7 +417,7 @@ napi_value JsKVStore::SetSyncRange(napi_env env, napi_callback_info info) auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->kvStore_; Status status = kvStore->SetCapabilityRange(ctxt->localLabels, ctxt->remoteSupportLabels); - ZLOGD("kvStore->SetCapabilityRange return %{public}d", status); + ZLOGD("kvStore->SetCapabilityRange return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->SetCapabilityRange() failed!"); }; @@ -437,7 +444,7 @@ void JsKVStore::OnDataChange(napi_env env, size_t argc, napi_value* argv, std::s CHECK_STATUS_RETURN_VOID(ctxt, "napi_typeof failed!"); CHECK_ARGS_RETURN_VOID(ctxt, valueType == napi_function, "invalid arg[2], i.e. invalid callback"); - ZLOGI("subscribe data change type %{public}d", type); + ZLOGI("subscribe data change type=%{public}d", type); auto proxy = reinterpret_cast(ctxt->native); std::lock_guard lck(proxy->listMutex_); for (auto& it : proxy->dataObserver_[type]) { @@ -558,6 +565,7 @@ void JsKVStore::OffSyncComplete(napi_env env, size_t argc, napi_value* argv, std */ napi_status JsKVStore::RegisterSyncCallback(std::shared_ptr callback) { + ZLOGD("in"); Status status = kvStore_->RegisterSyncCallback(callback); if (status != Status::SUCCESS) { callback->Clear(); @@ -572,6 +580,7 @@ napi_status JsKVStore::UnRegisterSyncCallback() { Status status = kvStore_->UnRegisterSyncCallback(); if (status != Status::SUCCESS) { + ZLOGE("unregister SyncCallback error status:%d", status); return napi_generic_failure; } std::lock_guard lck(listMutex_); @@ -586,7 +595,7 @@ napi_status JsKVStore::Subscribe(uint8_t type, std::shared_ptr obs { auto subscribeType = ToSubscribeType(type); Status status = kvStore_->SubscribeKvStore(subscribeType, observer); - ZLOGD("kvStore_->SubscribeKvStore(%{public}d) return %{public}d", type, status); + ZLOGD("kvStore_->SubscribeKvStore type=%{public}d, return status=%{public}d", type, status); if (status != Status::SUCCESS) { observer->Clear(); return napi_generic_failure; @@ -599,7 +608,7 @@ napi_status JsKVStore::UnSubscribe(uint8_t type, std::shared_ptr o { auto subscribeType = ToSubscribeType(type); Status status = kvStore_->UnSubscribeKvStore(subscribeType, observer); - ZLOGD("kvStore_->UnSubscribeKvStore(%{public}d) return %{public}d", type, status); + ZLOGD("kvStore_->UnSubscribeKvStore type=%{public}d, return status=%{public}d", type, status); if (status == Status::SUCCESS) { observer->Clear(); return napi_ok; @@ -615,14 +624,14 @@ void JsKVStore::SetUvQueue(std::shared_ptr uvQueue) void JsKVStore::DataObserver::OnChange(const ChangeNotification ¬ification, std::shared_ptr snapshot) { - ZLOGD("data change insert:%{public}zu, update:%{public}zu, delete:%{public}zu", + ZLOGD("data change insert=%{public}zu, update=%{public}zu, delete=%{public}zu", notification.GetInsertEntries().size(), notification.GetUpdateEntries().size(), notification.GetDeleteEntries().size()); } -void JsKVStore::DataObserver::OnChange(const ChangeNotification& notification) +void DataObserver::OnChange(const ChangeNotification& notification) { - ZLOGD("data change insert:%{public}zu, update:%{public}zu, delete:%{public}zu", + ZLOGD("data change insert=%{public}zu, update=%{public}zu, delete=%{public}zu", notification.GetInsertEntries().size(), notification.GetUpdateEntries().size(), notification.GetDeleteEntries().size()); KvStoreObserver::OnChange(notification); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp b/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp index 4605d44c7..3ca019cab 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_kv_store_resultset.cpp @@ -33,6 +33,7 @@ std::shared_ptr& JsKVStoreResultSet::GetNative() napi_value JsKVStoreResultSet::Constructor(napi_env env) { + ZLOGD("KVManager::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("getCount", JsKVStoreResultSet::GetCount), DECLARE_NAPI_FUNCTION("getPosition", JsKVStoreResultSet::GetPosition), @@ -188,7 +189,7 @@ napi_value JsKVStoreResultSet::MoveToPosition(napi_env env, napi_callback_info i }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - ZLOGD("KVStoreResultSet::MoveToPosition(%{public}d)", position); + ZLOGD("KVStoreResultSet::MoveToPosition position=%{public}d", position); auto& resultSet = reinterpret_cast(ctxt->native)->resultSet_; bool isMoved = resultSet->MoveToPosition(position); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_query.cpp b/frameworks/jskitsimpl/distributeddata/src/js_query.cpp index 7f59047ed..d691f4ceb 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_query.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_query.cpp @@ -67,6 +67,7 @@ napi_value JsQuery::Constructor(napi_env env) */ napi_value JsQuery::New(napi_env env, napi_callback_info info) { + ZLOGD("Query::New()"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -346,6 +347,7 @@ struct NumbersContext : public ContextBase { napi_value JsQuery::InNumber(napi_env env, napi_callback_info info) { + ZLOGD("Query::InNumber()"); auto ctxt = std::make_shared(); ctxt->GetNumberSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -363,6 +365,7 @@ napi_value JsQuery::InNumber(napi_env env, napi_callback_info info) napi_value JsQuery::InString(napi_env env, napi_callback_info info) { + ZLOGD("Query::InString()"); struct StringsContext : public ContextBase { std::string field; std::vector valueList; @@ -386,6 +389,7 @@ napi_value JsQuery::InString(napi_env env, napi_callback_info info) napi_value JsQuery::NotInNumber(napi_env env, napi_callback_info info) { + ZLOGD("Query::NotInNumber()"); auto ctxt = std::make_shared(); ctxt->GetNumberSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); @@ -537,6 +541,7 @@ napi_value JsQuery::OrderByDesc(napi_env env, napi_callback_info info) napi_value JsQuery::Limit(napi_env env, napi_callback_info info) { + ZLOGD("Query::Limit()"); struct LimitContext : public ContextBase { int number; int offset; @@ -601,6 +606,7 @@ napi_value JsQuery::EndGroup(napi_env env, napi_callback_info info) napi_value JsQuery::PrefixKey(napi_env env, napi_callback_info info) { + ZLOGD("Query::PrefixKey()"); std::string prefix; auto ctxt = std::make_shared(); auto input = [env, ctxt, &prefix](size_t argc, napi_value* argv) { @@ -619,6 +625,7 @@ napi_value JsQuery::PrefixKey(napi_env env, napi_callback_info info) napi_value JsQuery::SetSuggestIndex(napi_env env, napi_callback_info info) { + ZLOGD("Query::SetSuggestIndex()"); std::string suggestIndex; auto ctxt = std::make_shared(); auto input = [env, ctxt, &suggestIndex](size_t argc, napi_value* argv) { @@ -637,6 +644,7 @@ napi_value JsQuery::SetSuggestIndex(napi_env env, napi_callback_info info) napi_value JsQuery::DeviceId(napi_env env, napi_callback_info info) { + ZLOGD("Query::DeviceId()"); std::string deviceId; auto ctxt = std::make_shared(); auto input = [env, ctxt, &deviceId](size_t argc, napi_value* argv) { @@ -656,6 +664,7 @@ napi_value JsQuery::DeviceId(napi_env env, napi_callback_info info) // getSqlLike():string napi_value JsQuery::GetSqlLike(napi_env env, napi_callback_info info) { + ZLOGD("Query::GetSqlLike()"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); diff --git a/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp b/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp index 5a457bb06..63e61c346 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_schema.cpp @@ -87,6 +87,7 @@ napi_status JsSchema::ToJson(napi_env env, napi_value inner, JsSchema*& out) JsSchema* JsSchema::GetSchema(napi_env env, napi_callback_info info, std::shared_ptr& ctxt) { + ZLOGD("Schema::GetSchema"); ctxt->GetCbInfoSync(env, info); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); return reinterpret_cast(ctxt->native); @@ -95,6 +96,7 @@ JsSchema* JsSchema::GetSchema(napi_env env, napi_callback_info info, std::shared template napi_value JsSchema::GetContextValue(napi_env env, std::shared_ptr& ctxt, T& value) { + ZLOGD("Schema::GetContextValue"); JSUtil::SetValue(env, value, ctxt->output); return ctxt->output; } @@ -152,6 +154,7 @@ napi_value JsSchema::GetMode(napi_env env, napi_callback_info info) napi_value JsSchema::SetMode(napi_env env, napi_callback_info info) { + ZLOGD("Schema::SetMode"); auto ctxt = std::make_shared(); uint32_t mode = false; auto input = [env, ctxt, &mode](size_t argc, napi_value* argv) { @@ -178,6 +181,7 @@ napi_value JsSchema::GetSkip(napi_env env, napi_callback_info info) napi_value JsSchema::SetSkip(napi_env env, napi_callback_info info) { + ZLOGD("Schema::SetSkip"); auto ctxt = std::make_shared(); uint32_t skip = false; auto input = [env, ctxt, &skip](size_t argc, napi_value* argv) { @@ -204,6 +208,7 @@ napi_value JsSchema::GetIndexes(napi_env env, napi_callback_info info) napi_value JsSchema::SetIndexes(napi_env env, napi_callback_info info) { + ZLOGD("Schema::SetIndexes"); auto ctxt = std::make_shared(); std::vector indexes; auto input = [env, ctxt, &indexes](size_t argc, napi_value* argv) { diff --git a/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp b/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp index 1444f488b..b7d13e0cb 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_single_kv_store.cpp @@ -31,6 +31,7 @@ JsSingleKVStore::JsSingleKVStore(const std::string& storeId) napi_value JsSingleKVStore::Constructor(napi_env env) { + ZLOGD("JsSingleKVStore::Constructor"); const napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("put", JsKVStore::Put), DECLARE_NAPI_FUNCTION("delete", JsKVStore::Delete), @@ -162,11 +163,11 @@ napi_value JsSingleKVStore::GetEntries(napi_env env, napi_callback_info info) if (ctxt->va.type == ArgsType::KEYPREFIX) { OHOS::DistributedKv::Key keyPrefix(ctxt->va.keyPrefix); status = kvStore->GetEntries(keyPrefix, ctxt->entries); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetEntriesWithQuery(query.ToString(), ctxt->entries); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetEntries() failed"); @@ -214,11 +215,11 @@ napi_value JsSingleKVStore::GetResultSet(napi_env env, napi_callback_info info) if (ctxt->va.type == ArgsType::KEYPREFIX) { OHOS::DistributedKv::Key keyPrefix(ctxt->va.keyPrefix); status = kvStore->GetResultSet(keyPrefix, kvResultSet); - ZLOGD("kvStore->GetEntries() return %{public}d", status); + ZLOGD("kvStore->GetEntries() return status=%{public}d", status); } else if (ctxt->va.type == ArgsType::QUERY) { auto query = ctxt->va.query->GetNative(); status = kvStore->GetResultSetWithQuery(query.ToString(), kvResultSet); - ZLOGD("kvStore->GetEntriesWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetEntriesWithQuery() return status=%{public}d", status); } ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetResultSet() failed!"); @@ -259,7 +260,7 @@ napi_value JsSingleKVStore::CloseResultSet(napi_env env, napi_callback_info info auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->CloseResultSet(ctxt->resultSet->GetNative()); - ZLOGD("kvStore->CloseResultSet return %{public}d", status); + ZLOGD("kvStore->CloseResultSet return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->CloseResultSet failed!"); }; @@ -293,7 +294,7 @@ napi_value JsSingleKVStore::GetResultSize(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); auto query = ctxt->query->GetNative(); Status status = kvStore->GetCountWithQuery(query.ToString(), ctxt->resultSize); - ZLOGD("kvStore->GetCountWithQuery() return %{public}d", status); + ZLOGD("kvStore->GetCountWithQuery() return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->GetCountWithQuery() failed!"); }; @@ -327,7 +328,7 @@ napi_value JsSingleKVStore::RemoveDeviceData(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->RemoveDeviceData(ctxt->deviceId); - ZLOGD("kvStore->RemoveDeviceData return %{public}d", status); + ZLOGD("kvStore->RemoveDeviceData return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "kvStore->RemoveDeviceData failed!"); }; @@ -362,12 +363,12 @@ napi_value JsSingleKVStore::Sync(napi_env env, napi_callback_info info) }; ctxt->GetCbInfoSync(env, info, input); NAPI_ASSERT(env, ctxt->status == napi_ok, "invalid arguments!"); - ZLOGD("sync deviceIdList.size=%{public}d, mode:%{public}u, allowedDelayMs:%{public}u", + ZLOGD("sync deviceIdList.size=%{public}d, mode=%{public}u, allowedDelayMs=%{public}u", (int)ctxt->deviceIdList.size(), ctxt->mode, ctxt->allowedDelayMs); auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->Sync(ctxt->deviceIdList, static_cast(ctxt->mode), ctxt->allowedDelayMs); - ZLOGD("kvStore->Sync return %{public}d!", status); + ZLOGD("kvStore->Sync return status=%{public}d!", status); NAPI_ASSERT(env, status == Status::SUCCESS, "kvStore->Sync() failed!"); return nullptr; } @@ -396,7 +397,7 @@ napi_value JsSingleKVStore::SetSyncParam(napi_env env, napi_callback_info info) auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); KvSyncParam syncParam { ctxt->allowedDelayMs }; Status status = kvStore->SetSyncParam(syncParam); - ZLOGD("kvStore->SetSyncParam return %{public}d", status); + ZLOGD("kvStore->SetSyncParam return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "output failed!"); }; @@ -420,7 +421,7 @@ napi_value JsSingleKVStore::GetSecurityLevel(napi_env env, napi_callback_info in auto execute = [ctxt]() { auto& kvStore = reinterpret_cast(ctxt->native)->GetNative(); Status status = kvStore->GetSecurityLevel(ctxt->securityLevel); - ZLOGD("kvStore->GetSecurityLevel return %{public}d", status); + ZLOGD("kvStore->GetSecurityLevel return status=%{public}d", status); ctxt->status = (status == Status::SUCCESS) ? napi_ok : napi_generic_failure; CHECK_STATUS_RETURN_VOID(ctxt, "GetSecurityLevel failed!"); }; diff --git a/frameworks/jskitsimpl/distributeddata/src/js_util.cpp b/frameworks/jskitsimpl/distributeddata/src/js_util.cpp index 30addf604..f8e60df5f 100644 --- a/frameworks/jskitsimpl/distributeddata/src/js_util.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/js_util.cpp @@ -94,7 +94,7 @@ napi_status JSUtil::GetValue(napi_env env, napi_value in, std::string& out) if (maxLen <= 0) { return status; } - ZLOGD("napi_value -> std::string get length %{public}d", (int)maxLen); + ZLOGD("napi_value -> std::string get length=%{public}d", (int)maxLen); char* buf = new (std::nothrow) char[maxLen + STR_TAIL_LENGTH]; if (buf != nullptr) { size_t len = 0; @@ -164,7 +164,7 @@ JSUtil::KvStoreVariant JSUtil::Blob2VariantValue(const DistributedKv::Blob& blob } // number 1 means: skip the first byte, byte[0] is real data type. std::vector real(data.begin() + 1, data.end()); - ZLOGD("Blob::type %{public}d size=%{public}d", static_cast(data[0]), static_cast(real.size())); + ZLOGD("Blob::type=%{public}d size=%{public}d", static_cast(data[0]), static_cast(real.size())); if (data[0] == JSUtil::INTEGER) { uint32_t tmp4int = be32toh(*reinterpret_cast(&(real[0]))); return JSUtil::KvStoreVariant(*reinterpret_cast(&tmp4int)); @@ -971,6 +971,7 @@ napi_ref JSUtil::NewWithRef(napi_env env, size_t argc, napi_value* argv, void** napi_status JSUtil::Unwrap(napi_env env, napi_value in, void** out, napi_value constructor) { + ZLOGD("JSUtil::Unwrap"); if (constructor != nullptr) { bool isInstance = false; napi_instanceof(env, in, constructor, &isInstance); diff --git a/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp b/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp index e09d7ac17..da336ed6f 100644 --- a/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp +++ b/frameworks/jskitsimpl/distributeddata/src/napi_queue.cpp @@ -119,10 +119,12 @@ void NapiQueue::GenerateOutput(ContextBase* ctxt) if (ctxt->status == napi_ok) { napi_get_undefined(ctxt->env, &result[RESULT_ERROR]); if (ctxt->output == nullptr) { + ZLOGD("ctxt->output is nullptr"); napi_get_undefined(ctxt->env, &ctxt->output); } result[RESULT_DATA] = ctxt->output; } else { + ZLOGD("ctxt->status != napi_ok"); napi_value message = nullptr; napi_create_string_utf8(ctxt->env, ctxt->error.c_str(), NAPI_AUTO_LENGTH, &message); napi_create_error(ctxt->env, nullptr, message, &result[RESULT_ERROR]); diff --git a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp index 70e2bfa3f..59d2c89e9 100644 --- a/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp +++ b/services/distributeddataservice/adapter/communicator/src/softbus_adapter_standard.cpp @@ -689,7 +689,7 @@ void AppDataListenerWrap::OnSessionClosed(int sessionId) } ret = GetPeerSessionName(sessionId, peerSessionName, sizeof(peerSessionName)); if (ret != SOFTBUS_OK) { - ZLOGW("get my peer session name failed."); + ZLOGW("get my peer session name failed, session id = %{public}d.", sessionId); return; } ret = GetPeerDeviceId(sessionId, peerDevId, sizeof(peerDevId)); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp index 5a12f0a13..4c6a0fc53 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/operation/database_oper.cpp @@ -519,6 +519,7 @@ int DatabaseOper::ClearImportTempFile(const KvDBProperties &property) const std::string exportBackupDir = workDir + "/" + dbSubDir + DBConstant::PATH_POSTFIX_UNPACKED; DBCommon::RemoveAllFilesOfDirectory(exportBackupDir); + LOGI("Clear the files while import"); if (isOriKeepFileExist && isBakKeepFileExist) { LOGE("Origin and backup file shouldn't exist concurrently"); } @@ -555,6 +556,7 @@ int DatabaseOper::ClearExportedTempFiles(const KvDBProperties &property) const int dbType = property.GetIntProp(KvDBProperties::DATABASE_TYPE, KvDBProperties::LOCAL_TYPE); std::string dbSubDir = KvDBProperties::GetStoreSubDirectory(dbType); std::string backupDir = workDir + "/" + dbSubDir + DBConstant::PATH_POSTFIX_EXPORT_BACKUP; + LOGI("Remove the exported files."); errCode = DBCommon::RemoveAllFilesOfDirectory(backupDir); if (errCode != E_OK) { LOGE("Remove the exported backup dir failed"); diff --git a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp index c43ef227d..be2cc3b9e 100644 --- a/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp +++ b/services/distributeddataservice/libs/distributeddb/storage/src/sqlite/relational/sqlite_relational_store_connection.cpp @@ -93,6 +93,7 @@ int SQLiteRelationalStoreConnection::StartTransaction() return errCode; } + LOGD("[RelationalConnection] Start transaction finish."); writeHandle_ = handle; return E_OK; } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp index 514a79354..9588a3a24 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/ability_sync.cpp @@ -133,7 +133,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const len += Parcel::GetUInt32Len(); // softwareVersion_ uint32_t schemLen = Parcel::GetStringLen(schema_); if (schemLen == 0) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] schemLen err!"); + LOGE("[AbilitySyncRequestPacket][CalculateLen] schemLen error!"); return 0; } len += schemLen; @@ -145,7 +145,7 @@ uint32_t AbilitySyncRequestPacket::CalculateLen() const // the reason why not 8-byte align is that old version is not 8-byte align // so it is not possible to set 8-byte align for high version. if (len > INT32_MAX) { - LOGE("[AbilitySyncRequestPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncRequestPacket][CalculateLen] error length=%llu", len); return 0; } return len; @@ -286,7 +286,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += Parcel::GetIntLen(); uint32_t schemLen = Parcel::GetStringLen(schema_); if (schemLen == 0) { - LOGE("[AbilitySyncAckPacket][CalculateLen] schemLen err!"); + LOGE("[AbilitySyncAckPacket][CalculateLen] schemLen error!"); return 0; } len += schemLen; @@ -299,7 +299,7 @@ uint32_t AbilitySyncAckPacket::CalculateLen() const len += DbAbility::CalculateLen(dbAbility_); // dbAbility_ len += SchemaNegotiate::CalculateParcelLen(relationalSyncOpinion_); if (len > INT32_MAX) { - LOGE("[AbilitySyncAckPacket][CalculateLen] err len:%llu", len); + LOGE("[AbilitySyncAckPacket][CalculateLen] error length=%llu", len); return 0; } return len; @@ -344,6 +344,7 @@ int AbilitySync::Initialize(ICommunicator *inCommunicator, ISyncInterface *inSto std::shared_ptr &inMetadata, const std::string &deviceId) { if (inCommunicator == nullptr || inStorage == nullptr || deviceId.empty() || inMetadata == nullptr) { + LOGE("[AbilitySync][Initialize] args error"); return -E_INVALID_ARGS; } communicator_ = inCommunicator; @@ -359,16 +360,18 @@ int AbilitySync::SyncStart(uint32_t sessionId, uint32_t sequenceId, uint16_t rem AbilitySyncRequestPacket packet; int errCode = SetAbilityRequestBodyInfo(packet, remoteCommunicatorVersion); if (errCode != E_OK) { + LOGE("[AbilitySync][SyncStart] set AbilityRequestBodyInfo error, errCode=%d", errCode); return errCode; } Message *message = new (std::nothrow) Message(ABILITY_SYNC_MESSAGE); if (message == nullptr) { + LOGE("[AbilitySync][SyncStart] message is nullptr"); return -E_OUT_OF_MEMORY; } message->SetMessageType(TYPE_REQUEST); errCode = message->SetCopiedObject<>(packet); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] SetCopiedObject failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] SetCopiedObject failed, errCode=%d", errCode); delete message; message = nullptr; return errCode; @@ -380,7 +383,7 @@ int AbilitySync::SyncStart(uint32_t sessionId, uint32_t sequenceId, uint16_t rem SetSendConfig(deviceId_, false, SEND_TIME_OUT, conf); errCode = communicator_->SendMessage(deviceId_, message, conf, handler); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] SendPacket failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] SendPacket failed, errCode=%d", errCode); delete message; message = nullptr; } @@ -391,10 +394,12 @@ int AbilitySync::AckRecv(const Message *message, ISyncTaskContext *context) { int errCode = AckMsgCheck(message, context); if (errCode != E_OK) { + LOGE("[AbilitySync][AckRecv] AckMsgCheck error, errCode=%d", errCode); return errCode; } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckRecv] get packet is nullptr"); return -E_INVALID_ARGS; } uint32_t remoteSoftwareVersion = packet->GetSoftwareVersion(); @@ -418,16 +423,18 @@ int AbilitySync::AckRecv(const Message *message, ISyncTaskContext *context) int AbilitySync::RequestRecv(const Message *message, ISyncTaskContext *context) { if (message == nullptr || context == nullptr) { + LOGE("[AbilitySync][RequestRecv] message or context is nullptr"); return -E_INVALID_ARGS; } const AbilitySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestRecv] get packet is nullptr"); return -E_INVALID_ARGS; } if (packet->GetSendCode() == -E_VERSION_NOT_SUPPORT) { AbilitySyncAckPacket ackPacket; (void)SendAck(message, -E_VERSION_NOT_SUPPORT, false, ackPacket); - LOGI("[AbilitySync][RequestRecv] version can not support, remote version is %u", packet->GetProtocolVersion()); + LOGI("[AbilitySync][RequestRecv] version can not support, remote version = %u", packet->GetProtocolVersion()); return -E_VERSION_NOT_SUPPORT; } @@ -444,6 +451,7 @@ int AbilitySync::RequestRecv(const Message *message, ISyncTaskContext *context) int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context) { if (message == nullptr || context == nullptr) { + LOGE("[AbilitySync][AckNotifyRecv] message or context is nullptr"); return -E_INVALID_ARGS; } if (message->GetErrorNo() == E_FEEDBACK_UNKNOWN_MESSAGE) { @@ -453,11 +461,12 @@ int AbilitySync::AckNotifyRecv(const Message *message, ISyncTaskContext *context } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckNotifyRecv] get packet is nullptr"); return -E_INVALID_ARGS; } int errCode = packet->GetAckCode(); if (errCode != E_OK) { - LOGE("[AbilitySync][AckNotifyRecv] received a errCode %d", errCode); + LOGE("[AbilitySync][AckNotifyRecv] received a errCode=%d", errCode); return errCode; } std::string schema = packet->GetSchema(); @@ -491,22 +500,24 @@ bool AbilitySync::SecLabelCheck(const AbilitySyncRequestPacket *packet) const int32_t remoteSecLabel = packet->GetSecLabel(); int32_t remoteSecFlag = packet->GetSecFlag(); if (remoteSecLabel == NOT_SURPPORT_SEC_CLASSIFICATION || remoteSecLabel == SecurityLabel::NOT_SET) { + LOGI("[AbilitySync][RequestRecv] remoteSecLabel not surpport or not set"); return true; } SecurityOption option; int errCode = (static_cast(storageInterface_))->GetSecurityOption(option); - LOGI("[AbilitySync][RequestRecv] local l:%d, f:%d, errCode:%d", option.securityLabel, option.securityFlag, errCode); + LOGI("[AbilitySync][RequestRecv] local label=%d, flag=%d, errCode=%d", + option.securityLabel, option.securityFlag, errCode); if (errCode == -E_NOT_SUPPORT || option.securityLabel == SecurityLabel::NOT_SET) { return true; } if (remoteSecLabel == FAILED_GET_SEC_CLASSIFICATION || errCode != E_OK) { - LOGE("[AbilitySync][RequestRecv] check error remoteL:%d, errCode:%d", remoteSecLabel, errCode); + LOGE("[AbilitySync][RequestRecv] check error remoteLable=%d, errCode=%d", remoteSecLabel, errCode); return false; } if (remoteSecLabel == option.securityLabel) { return true; } else { - LOGE("[AbilitySync][RequestRecv] check error remote:%d , %d local:%d , %d", + LOGE("[AbilitySync][RequestRecv] check error remote:lable=%d,flag=%d, local:lable=%d,flag=%d", remoteSecLabel, remoteSecFlag, option.securityLabel, option.securityFlag); return false; } @@ -540,6 +551,7 @@ int AbilitySync::HandleVersionV3AckSchemaParam(const AbilitySyncAckPacket *recvP AbilitySyncAckPacket &sendPacket, ISyncTaskContext *context, bool sendOpinion) const { if (IsSingleRelationalVer()) { + LOGI("[AbilitySync][HandleVersionV3AckSchemaParam] Single Relational Ver"); return HandleRelationAckSchemaParam(recvPacket, sendPacket, context, sendOpinion); } HandleKvAckSchemaParam(recvPacket, context, sendPacket); @@ -557,7 +569,7 @@ void AbilitySync::GetPacketSecOption(SecurityOption &option) const LOGE("[AbilitySync][SyncStart] GetSecOpt not surpport sec classification"); option.securityLabel = NOT_SURPPORT_SEC_CLASSIFICATION; } else if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetSecOpt errCode:%d", errCode); + LOGE("[AbilitySync][SyncStart] GetSecOpt errCode=%d", errCode); option.securityLabel = FAILED_GET_SEC_CLASSIFICATION; } } @@ -576,6 +588,7 @@ int AbilitySync::RegisterTransformFunc() uint32_t AbilitySync::CalculateLen(const Message *inMsg) { if ((inMsg == nullptr) || (inMsg->GetMessageId() != ABILITY_SYNC_MESSAGE)) { + LOGE("[AbilitySync][CalculateLen] message is nullptr or messageid not true"); return 0; } int errCode; @@ -584,23 +597,23 @@ uint32_t AbilitySync::CalculateLen(const Message *inMsg) case TYPE_REQUEST: errCode = RequestPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] request packet calc length err %d", errCode); + LOGE("[AbilitySync][CalculateLen] request packet calc length err=%d", errCode); } break; case TYPE_RESPONSE: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] ack packet calc length err %d", errCode); + LOGE("[AbilitySync][CalculateLen] ack packet calc length err=%d", errCode); } break; case TYPE_NOTIFY: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { - LOGE("[AbilitySync][CalculateLen] ack packet calc length err %d", errCode); + LOGE("[AbilitySync][CalculateLen] ack packet calc length err=%d", errCode); } break; default: - LOGE("[AbilitySync][CalculateLen] message type not support, type %d", inMsg->GetMessageType()); + LOGE("[AbilitySync][CalculateLen] message type not support, type=%d", inMsg->GetMessageType()); break; } return len; @@ -609,6 +622,7 @@ uint32_t AbilitySync::CalculateLen(const Message *inMsg) int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("[AbilitySync][Serialization] buffer or message is nullptr"); return -E_INVALID_ARGS; } @@ -620,6 +634,7 @@ int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message * case TYPE_NOTIFY: return AckPacketSerialization(buffer, length, inMsg); default: + LOGE("[AbilitySync][Serialization] message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -627,6 +642,7 @@ int AbilitySync::Serialization(uint8_t *buffer, uint32_t length, const Message * int AbilitySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("[AbilitySync][DeSerialization] buffer or message is nullptr"); return -E_INVALID_ARGS; } @@ -638,6 +654,7 @@ int AbilitySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message case TYPE_NOTIFY: return AckPacketDeSerialization(buffer, length, inMsg); default: + LOGE("[AbilitySync][DeSerialization] message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -646,6 +663,7 @@ int AbilitySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { const AbilitySyncRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestPacketCalculateLen] get packet is nullptr"); return -E_INVALID_ARGS; } @@ -657,6 +675,7 @@ int AbilitySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { const AbilitySyncAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckPacketCalculateLen] get packet is nullptr"); return -E_INVALID_ARGS; } @@ -668,6 +687,7 @@ int AbilitySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, co { const AbilitySyncRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("[AbilitySync][RequestPacketSerialization]get packet is nullptr or length error"); return -E_INVALID_ARGS; } @@ -682,6 +702,7 @@ int AbilitySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, co parcel.WriteUInt64(packet->GetDbCreateTime()); int errCode = DbAbility::Serialize(parcel, packet->GetDbAbility()); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][RequestPacketSerialization] Serialize error errCode=%d", errCode); return -E_PARSE_FAIL; } return E_OK; @@ -691,6 +712,7 @@ int AbilitySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const { const AbilitySyncAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("[AbilitySync][AckPacketSerialization] get packet is nullptr or length error"); return -E_INVALID_ARGS; } @@ -707,10 +729,12 @@ int AbilitySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const parcel.WriteUInt64(packet->GetDbCreateTime()); int errCode = DbAbility::Serialize(parcel, packet->GetDbAbility()); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][AckPacketSerialization] Serialize error errCode=%d", errCode); return -E_PARSE_FAIL; } errCode = SchemaNegotiate::SerializeData(packet->GetRelationalSyncOpinion(), parcel); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][AckPacketSerialization] SerializeData error errCode=%d", errCode); return -E_PARSE_FAIL; } return E_OK; @@ -720,6 +744,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le { auto *packet = new (std::nothrow) AbilitySyncRequestPacket(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestPacketDeSerialization] get packet is nullptr"); return -E_OUT_OF_MEMORY; } @@ -732,6 +757,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le parcel.ReadUInt32(version); if (parcel.IsError()) { + LOGE("[AbilitySync][RequestPacketDeSerialization] parcel is error"); goto ERROR_OUT; } packet->SetProtocolVersion(version); @@ -739,6 +765,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le packet->SetSendCode(-E_VERSION_NOT_SUPPORT); errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("[AbilitySync][RequestPacketDeSerialization] SetExternalObject error errCode=%d", errCode); goto ERROR_OUT; } return errCode; @@ -748,6 +775,7 @@ int AbilitySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t le parcel.ReadString(schema); errCode = RequestPacketDeSerializationTailPart(parcel, packet, softwareVersion); if (parcel.IsError() || errCode != E_OK) { + LOGE("[AbilitySync][RequestPacketDeSerialization] RequestPacketDeSerializationTailPart error errCode=%d", errCode); goto ERROR_OUT; } packet->SetSendCode(sendCode); @@ -787,7 +815,7 @@ int AbilitySync::RequestPacketDeSerializationTailPart(Parcel &parcel, AbilitySyn DbAbility remoteDbAbility; int errCode = DbAbility::DeSerialize(parcel, remoteDbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync] request packet DeSerializ failed."); + LOGE("[AbilitySync] request packet DeSerializ failed, errCode=%d", errCode); return errCode; } packet->SetDbAbility(remoteDbAbility); @@ -821,14 +849,14 @@ int AbilitySync::AckPacketDeSerializationTailPart(Parcel &parcel, AbilitySyncAck DbAbility remoteDbAbility; int errCode = DbAbility::DeSerialize(parcel, remoteDbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync] ack packet DeSerializ failed."); + LOGE("[AbilitySync] ack packet DeSerializ failed, errCode=%d", errCode); return errCode; } packet->SetDbAbility(remoteDbAbility); RelationalSyncOpinion relationalSyncOpinion; errCode = SchemaNegotiate::DeserializeData(parcel, relationalSyncOpinion); if (errCode != E_OK) { - LOGE("[AbilitySync] ack packet DeSerializ RelationalSyncOpinion failed."); + LOGE("[AbilitySync] ack packet DeSerializ RelationalSyncOpinion failed, errCode=%d", errCode); return errCode; } packet->SetRelationalSyncOpinion(relationalSyncOpinion); @@ -839,6 +867,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length { auto *packet = new (std::nothrow) AbilitySyncAckPacket(); if (packet == nullptr) { + LOGE("[AbilitySync][RequestDeSerialization] get packet is nullptr"); return -E_OUT_OF_MEMORY; } @@ -859,6 +888,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length packet->SetAckCode(-E_VERSION_NOT_SUPPORT); errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("[AckPacketDeSerialization] ack packet SetExternalObject failed, errCode=%d", errCode); goto ERROR_OUT; } return errCode; @@ -868,7 +898,7 @@ int AbilitySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length parcel.ReadString(schema); errCode = AckPacketDeSerializationTailPart(parcel, packet, softwareVersion); if (parcel.IsError() || errCode != E_OK) { - LOGE("[AbilitySync][RequestDeSerialization] DeSerialization failed!"); + LOGE("[AbilitySync][RequestDeSerialization] DeSerialization failed, errCode=%d", errCode); errCode = -E_PARSE_FAIL; goto ERROR_OUT; } @@ -892,7 +922,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin int errCode = (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDatabaseCreateTimeStamp failed, err %d", errCode); + LOGE("[AbilitySync][SetAbilityRequestBodyInfo] GetDatabaseCreateTimeStamp failed, err=%d", errCode); return errCode; } SecurityOption option; @@ -911,7 +941,7 @@ int AbilitySync::SetAbilityRequestBodyInfo(AbilitySyncRequestPacket &packet, uin DbAbility dbAbility; errCode = GetDbAbilityInfo(dbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDbAbility failed, err %d", errCode); + LOGE("[AbilitySync][SetAbilityRequestBodyInfo] GetDbAbility failed, err=%d", errCode); return errCode; } // 102 version is forbidden to sync with 103 json-schema or flatbuffer-schema @@ -948,13 +978,13 @@ int AbilitySync::SetAbilityAckBodyInfo(AbilitySyncAckPacket &ackPacket, int ackC errCode = (static_cast(storageInterface_))->GetDatabaseCreateTimeStamp(dbCreateTime); if (errCode != E_OK) { - LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err %d", errCode); + LOGE("[AbilitySync][SyncStart] GetDatabaseCreateTimeStamp failed, err=%d", errCode); ackCode = errCode; } DbAbility dbAbility; errCode = GetDbAbilityInfo(dbAbility); if (errCode != E_OK) { - LOGE("[AbilitySync][FillAbilityRequest] GetDbAbility failed, err %d", errCode); + LOGE("[AbilitySync][SetAbilityAckBodyInfo] GetDbAbility failed, err=%d", errCode); return errCode; } ackPacket.SetDbCreateTime(dbCreateTime); @@ -982,6 +1012,7 @@ int AbilitySync::GetDbAbilityInfo(DbAbility &dbAbility) const for (const auto &item : SyncConfig::ABILITYBITS) { errCode = dbAbility.SetAbilityItem(item, SUPPORT_MARK); if (errCode != E_OK) { + LOGE("[AbilitySync][GetDbAbilityInfo] SetAbilityItem failed, err=%d", errCode); return errCode; } } @@ -991,6 +1022,7 @@ int AbilitySync::GetDbAbilityInfo(DbAbility &dbAbility) const int AbilitySync::AckMsgCheck(const Message *message, ISyncTaskContext *context) const { if (message == nullptr || context == nullptr) { + LOGE("[AbilitySync][AckMsgCheck] message or context is nullptr"); return -E_INVALID_ARGS; } if (message->GetErrorNo() == E_FEEDBACK_UNKNOWN_MESSAGE) { @@ -1006,11 +1038,12 @@ int AbilitySync::AckMsgCheck(const Message *message, ISyncTaskContext *context) } const AbilitySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][AckMsgCheck] packet is nullptr"); return -E_INVALID_ARGS; } int ackCode = packet->GetAckCode(); if (ackCode != E_OK) { - LOGE("[AbilitySync][AckMsgCheck] received an errCode %d", ackCode); + LOGE("[AbilitySync][AckMsgCheck] received an errCode=%d", ackCode); context->SetTaskErrCode(ackCode); return ackCode; } @@ -1034,6 +1067,7 @@ int AbilitySync::HandleRequestRecv(const Message *message, ISyncTaskContext *con { const AbilitySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("[AbilitySync][HandleRequestRecv] packet is nullptr"); return -E_INVALID_ARGS; } uint32_t remoteSoftwareVersion = packet->GetSoftwareVersion(); @@ -1068,6 +1102,7 @@ int AbilitySync::SendAck(const Message *message, int ackCode, bool isAckNotify, { int errCode = SetAbilityAckBodyInfo(ackPacket, ackCode, isAckNotify); if (errCode != E_OK) { + LOGE("[AbilitySync][SendAck] SetAbilityAckBodyInfo error errCode=%d", errCode); return errCode; } if (IsSingleRelationalVer()) { @@ -1086,6 +1121,7 @@ int AbilitySync::SendAckWithEmptySchema(const Message *message, int ackCode, AbilitySyncAckPacket ackPacket; int errCode = SetAbilityAckBodyInfo(ackPacket, ackCode, isAckNotify); if (errCode != E_OK) { + LOGE("[AbilitySync][SendAckWithEmptySchema] SetAbilityAckBodyInfo error errCode=%d", errCode); return errCode; } SetAbilityAckSchemaInfo(ackPacket, SchemaObject()); @@ -1101,7 +1137,7 @@ int AbilitySync::SendAck(const Message *inMsg, const AbilitySyncAckPacket &ackPa } int errCode = ackMessage->SetCopiedObject<>(ackPacket); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SetCopiedObject failed, err %d", errCode); + LOGE("[AbilitySync][SendAck] SetCopiedObject failed, err=%d", errCode); delete ackMessage; ackMessage = nullptr; return errCode; @@ -1114,7 +1150,7 @@ int AbilitySync::SendAck(const Message *inMsg, const AbilitySyncAckPacket &ackPa SetSendConfig(deviceId_, false, SEND_TIME_OUT, conf); errCode = communicator_->SendMessage(deviceId_, ackMessage, conf); if (errCode != E_OK) { - LOGE("[AbilitySync][SendAck] SendPacket failed, err %d", errCode); + LOGE("[AbilitySync][SendAck] SendPacket failed, err=%d", errCode); delete ackMessage; ackMessage = nullptr; } @@ -1192,6 +1228,7 @@ int AbilitySync::AckRecvWithHighVersion(const Message *message, ISyncTaskContext AbilitySyncAckPacket ackPacket; int errCode = HandleVersionV3AckSchemaParam(packet, ackPacket, context, true); if (errCode != E_OK) { + LOGE("[AbilitySync][AckRecvWithHighVersion] HandleVersionV3AckSchemaParam failed,errCode=%d", errCode); return errCode; } auto singleVerContext = static_cast(context); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp index ffb3c0e36..0e2dd38ea 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/commit_history_sync.cpp @@ -141,6 +141,7 @@ CommitHistorySync::~CommitHistorySync() int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("CommitHistorySync::Serialization buffer is nullptr or error in validity of package."); return -E_MESSAGE_ID_ERROR; } @@ -150,6 +151,7 @@ int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Mes case TYPE_RESPONSE: return AckPacketSerialization(buffer, length, inMsg); default: + LOGE("CommitHistorySync::Serialization message type error."); return -E_MESSAGE_TYPE_ERROR; } } @@ -157,6 +159,7 @@ int CommitHistorySync::Serialization(uint8_t *buffer, uint32_t length, const Mes int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("CommitHistorySync::DeSerialization buffer is nullptr or error in validity of package."); return -E_MESSAGE_ID_ERROR; } @@ -166,6 +169,7 @@ int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, M case TYPE_RESPONSE: return AckPacketDeSerialization(buffer, length, inMsg); default: + LOGE("CommitHistorySync::DeSerialization message type error."); return -E_MESSAGE_TYPE_ERROR; } } @@ -173,6 +177,7 @@ int CommitHistorySync::DeSerialization(const uint8_t *buffer, uint32_t length, M uint32_t CommitHistorySync::CalculateLen(const Message *inMsg) { if (!(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("CommitHistorySync::CalculateLen error in validity of package."); return 0; } @@ -182,12 +187,14 @@ uint32_t CommitHistorySync::CalculateLen(const Message *inMsg) case TYPE_REQUEST: errCode = RequestPacketCalculateLen(inMsg, len); if (errCode != E_OK) { + LOGE("CommitHistorySync::CalculateLen request packet calculateLen error=%d.", errCode); return 0; } return len; case TYPE_RESPONSE: errCode = AckPacketCalculateLen(inMsg, len); if (errCode != E_OK) { + LOGE("CommitHistorySync::CalculateLen ack packet calculateLen error=%d.", errCode); return 0; } return len; @@ -210,6 +217,7 @@ int CommitHistorySync::RegisterTransformFunc() int CommitHistorySync::Initialize(MultiVerKvDBSyncInterface *storagePtr, ICommunicator *communicateHandle) { if ((storagePtr == nullptr) || (communicateHandle == nullptr)) { + LOGE("CommitHistorySync::Initialize storagePtr or communicateHandle is nullptr"); return -E_INVALID_ARGS; } storagePtr_ = storagePtr; @@ -227,6 +235,7 @@ void CommitHistorySync::TimeOutCallback(MultiVerSyncTaskContext *context, const int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) { if (context == nullptr) { + LOGE("CommitHistorySync::SyncStart context is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); @@ -239,6 +248,7 @@ int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_GET_DEVICE_LATEST_COMMIT); } if ((errCode != E_OK) && (errCode != -E_NOT_FOUND)) { + LOGE("CommitHistorySync::SyncStart get device latest commit error=%d.", errCode); return errCode; } @@ -249,16 +259,18 @@ int CommitHistorySync::SyncStart(MultiVerSyncTaskContext *context) int CommitHistorySync::RequestRecvCallback(const MultiVerSyncTaskContext *context, const Message *message) { if (!IsPacketValid(message, TYPE_REQUEST) || context == nullptr) { + LOGE("CommitHistorySync::RequestRecvCallback error in validity of package or context is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::RequestRecvCallback packet is nullptr."); return -E_INVALID_ARGS; } std::vector commits; int errCode = RunPermissionCheck(context->GetDeviceId()); if (errCode == -E_NOT_PERMIT) { - LOGE("CommitHistorySync::RequestRecvCallback RunPermissionCheck not pass"); + LOGE("CommitHistorySync::RequestRecvCallback RunPermissionCheck not pass error=%d", errCode); SendAckPacket(context, commits, errCode, message); return errCode; } @@ -292,6 +304,7 @@ int CommitHistorySync::RequestRecvCallback(const MultiVerSyncTaskContext *contex int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const Message *message) { if (!IsPacketValid(message, TYPE_RESPONSE) || (context == nullptr)) { + LOGE("CommitHistorySync::AckRecvCallback error in validity of package or context is nullptr."); return -E_INVALID_ARGS; } @@ -300,6 +313,7 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M const CommitHistorySyncAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::AckRecvCallback packet is nullptr."); return -E_INVALID_ARGS; } packet->GetErrorCode(errCode); @@ -320,14 +334,17 @@ int CommitHistorySync::AckRecvCallback(MultiVerSyncTaskContext *context, const M int CommitHistorySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (inMsg == nullptr) { + LOGE("CommitHistorySync::RequestPacketCalculateLen inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::RequestPacketCalculateLen packet is nullptr."); return -E_INVALID_ARGS; } if ((inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE) || (inMsg->GetMessageType() != TYPE_REQUEST)) { + LOGE("CommitHistorySync::RequestPacketCalculateLen get message error."); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -337,10 +354,12 @@ int CommitHistorySync::RequestPacketCalculateLen(const Message *inMsg, uint32_t int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("CommitHistorySync::RequestPacketSerialization buffer or inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("CommitHistorySync::RequestPacketSerialization packet is nullptr or packet length error."); return -E_INVALID_ARGS; } @@ -350,25 +369,31 @@ int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t leng int errCode = parcel.WriteUInt64(commitMap.size()); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write size error=%d.", errCode); return -E_SECUREC_ERROR; } // commitMap Serialization for (auto &iter : commitMap) { errCode = parcel.WriteString(iter.first); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write item error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteMultiVerCommit(iter.second); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write" + " multivercommit error:%d.", errCode); return -E_SECUREC_ERROR; } } errCode = parcel.WriteUInt32(packet->GetVersion()); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel write version error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteVector(packet->GetReserved()); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketSerialization parcel get reserved error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -378,6 +403,7 @@ int CommitHistorySync::RequestPacketSerialization(uint8_t *buffer, uint32_t leng int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("CommitHistorySync::RequestPacketDeSerialization buffer or inMsg is nullptr"); return -E_INVALID_ARGS; } @@ -399,6 +425,7 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 commitMap[key] = val; len--; if (parcel.IsError()) { + LOGE("CommitHistorySync::RequestPacketDeSerialization parcel error."); return -E_INVALID_ARGS; } } @@ -422,6 +449,7 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 packet->SetReserved(reserved); int errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("CommitHistorySync::RequestPacketDeSerialization packet set external object error=%d", errCode); delete packet; packet = nullptr; } @@ -431,14 +459,17 @@ int CommitHistorySync::RequestPacketDeSerialization(const uint8_t *buffer, uint3 int CommitHistorySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (inMsg == nullptr) { + LOGE("CommitHistorySync::AckPacketCalculateLen inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("CommitHistorySync::AckPacketCalculateLen packet is nullptr."); return -E_INVALID_ARGS; } if ((inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE) || (inMsg->GetMessageType() != TYPE_RESPONSE)) { + LOGE("CommitHistorySync::AckPacketCalculateLen get message error."); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -448,10 +479,12 @@ int CommitHistorySync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || (inMsg == nullptr)) { + LOGE("CommitHistorySync::AckPacketSerialization buffer or inMsg is nullptr."); return -E_INVALID_ARGS; } const CommitHistorySyncAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("CommitHistorySync::AckPacketSerialization packet is nullptr or lengeh error."); return -E_INVALID_ARGS; } @@ -464,10 +497,12 @@ int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, // errCode Serialization int errCode = parcel.WriteInt(ackErrCode); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel write ErrCode error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteUInt32(packet->GetVersion()); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel write version error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -475,10 +510,12 @@ int CommitHistorySync::AckPacketSerialization(uint8_t *buffer, uint32_t length, // commits vector Serialization errCode = parcel.WriteMultiVerCommits(commits); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel write MultiVerCommits error=%d.", errCode); return -E_SECUREC_ERROR; } errCode = parcel.WriteVector(packet->GetReserved()); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketSerialization parcel get reserved error=%d.", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -519,6 +556,7 @@ int CommitHistorySync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t packet->SetReserved(reserved); int errCode = inMsg->SetExternalObject<>(packet); if (errCode != E_OK) { + LOGE("CommitHistorySync::AckPacketDeSerialization set external object error=%d.", errCode); delete packet; packet = nullptr; } @@ -531,6 +569,7 @@ bool CommitHistorySync::IsPacketValid(const Message *inMsg, uint16_t messageType return false; } if (messageType != inMsg->GetMessageType()) { + LOGE("CommitHistorySync::IsPacketValid messageType error."); return false; } return true; @@ -538,7 +577,7 @@ bool CommitHistorySync::IsPacketValid(const Message *inMsg, uint16_t messageType int CommitHistorySync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("CommitHistorySync::Send ERR! err = %d", errCode); @@ -551,6 +590,7 @@ int CommitHistorySync::GetDeviceLatestCommit(std::map readCommitMap; int errCode = storagePtr_->GetDeviceLatestCommit(readCommitMap); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetDeviceLatestCommit get device latest commit ERR! err = %d", errCode); return errCode; } @@ -564,6 +604,7 @@ int CommitHistorySync::GetDeviceLatestCommit(std::mapTransferSyncCommitDevInfo(item.second, localDevice, false); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetDeviceLatestCommit transfer synccommit devInfo ERR! err = %d", errCode); break; } commitMap.insert(std::make_pair(item.second.deviceInfo, item.second)); @@ -579,7 +620,7 @@ int CommitHistorySync::GetCommitTree(const std::mapTransferSyncCommitDevInfo(commitNode, localDevice, true); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetCommitTree commitNode TransferSyncCommitDevInfo error = %d", errCode); return errCode; } newCommitMap.insert(std::make_pair(commitNode.deviceInfo, commitNode)); @@ -595,11 +637,13 @@ int CommitHistorySync::GetCommitTree(const std::mapGetCommitTree(newCommitMap, commits); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetCommitTree GetCommitTree error = %d", errCode); return errCode; } for (auto &commit : commits) { errCode = storagePtr_->TransferSyncCommitDevInfo(commit, localDevice, false); if (errCode != E_OK) { + LOGE("CommitHistorySync::GetCommitTree commit TransferSyncCommitDevInfo error = %d", errCode); break; } } @@ -631,7 +675,7 @@ int CommitHistorySync::SendRequestPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete message; message = nullptr; - LOGE("CommitHistorySync::SendRequestPacket : SetExternalObject failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendRequestPacket : SetExternalObject failed errCode=%d", errCode); return errCode; } message->SetSessionId(context->GetRequestSessionId()); @@ -643,7 +687,7 @@ int CommitHistorySync::SendRequestPacket(const MultiVerSyncTaskContext *context, } errCode = Send(message->GetTarget(), message); if (errCode != E_OK) { - LOGE("CommitHistorySync::SendRequestPacket : Send failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendRequestPacket : Send failed errCode=%d", errCode); delete message; message = nullptr; } @@ -681,14 +725,14 @@ int CommitHistorySync::SendAckPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete ackMessage; ackMessage = nullptr; - LOGE("CommitHistorySync::SendAckPacket : SetExternalObject failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendAckPacket : SetExternalObject failed errCode=%d", errCode); return errCode; } ackMessage->SetSequenceId(message->GetSequenceId()); ackMessage->SetSessionId(message->GetSessionId()); errCode = Send(ackMessage->GetTarget(), ackMessage); if (errCode != E_OK) { - LOGE("CommitHistorySync::SendAckPacket : Send failed errCode:%d", errCode); + LOGE("CommitHistorySync::SendAckPacket : Send failed errCode=%d", errCode); delete ackMessage; ackMessage = nullptr; } @@ -708,7 +752,7 @@ int CommitHistorySync::RunPermissionCheck(const std::string &deviceId) const uint8_t flag = CHECK_FLAG_SEND; int errCode = RuntimeContext::GetInstance()->RunPermissionCheck(userId, appId, storeId, deviceId, flag); if (errCode != E_OK) { - LOGE("[CommitHistorySync] RunPermissionCheck not pass errCode:%d, flag:%d", errCode, flag); + LOGE("[CommitHistorySync] RunPermissionCheck not pass errCode=%d, flag=%d", errCode, flag); return -E_NOT_PERMIT; } return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp index 3eef85f24..55f12a119 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/communicator_proxy.cpp @@ -101,6 +101,7 @@ void CommunicatorProxy::Activate() uint32_t CommunicatorProxy::GetCommunicatorMtuSize() const { if (mainComm_ == nullptr) { + LOGD("[GetCommunicatorMtuSize] mainComm_ is nullptr"); return DBConstant::MIN_MTU_SIZE; } return mainComm_->GetCommunicatorMtuSize(); @@ -132,6 +133,7 @@ uint32_t CommunicatorProxy::GetCommunicatorMtuSize(const std::string &target) co uint32_t CommunicatorProxy::GetTimeout() const { if (mainComm_ == nullptr) { + LOGD("[GetTimeout] mainComm_ is nullptr"); return DBConstant::MIN_TIMEOUT; } return mainComm_->GetTimeout(); @@ -181,6 +183,7 @@ int CommunicatorProxy::GetRemoteCommunicatorVersion(const std::string &target, u } } if (targetCommunicator != nullptr) { + LOGD("[GetRemoteCommunicatorVersion] use equal label to get data"); int errCode = targetCommunicator->GetRemoteCommunicatorVersion(target, outVersion); RefObject::DecObjRef(targetCommunicator); return errCode; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp index e8885f87a..74a67fb72 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/device_manager.cpp @@ -58,6 +58,7 @@ int DeviceManager::Initialize(ICommunicator *communicator, const std::function &offlineCallback) { if (communicator == nullptr) { + LOGE("[Initialize] communicator is nullptr"); return -E_INVALID_ARGS; } RefObject::IncObjRef(communicator); @@ -115,7 +116,7 @@ int DeviceManager::SendBroadCast(uint32_t msgId) if (msgId == LOCAL_DATA_CHANGED) { return SendLocalDataChanged(); } - LOGE("[DeviceManager] invalid BroadCast msgId:%u", msgId); + LOGE("[DeviceManager] invalid BroadCast msgId=%u", msgId); return -E_INVALID_ARGS; } @@ -138,10 +139,10 @@ int DeviceManager::SendLocalDataChanged() } msg->SetMessageId(LOCAL_DATA_CHANGED); msg->SetTarget(deviceId); - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicator_->SendMessage(deviceId, msg, conf); if (errCode != E_OK) { - LOGE("[DeviceManager] SendLocalDataChanged to dev %s{private} failed. err %d", + LOGE("[DeviceManager] SendLocalDataChanged to dev=%s{private} failed. err=%d", deviceId.c_str(), errCode); delete msg; msg = nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp index b91f2549f..e691bdb0c 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/generic_syncer.cpp @@ -104,6 +104,7 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) } int errCode = CheckSyncActive(syncInterface, isNeedActive); if (errCode != E_OK) { + LOGE("[Syncer] check sync active failed err=%d", errCode); return errCode; } @@ -120,6 +121,7 @@ int GenericSyncer::Initialize(ISyncInterface *syncInterface, bool isNeedActive) errCode = InitSyncEngine(syncInterface); if (errCode != E_OK) { + LOGE("[Syncer] init sync engine failed err=%d", errCode); return errCode; } syncEngine_->SetEqualIdentifier(); @@ -187,17 +189,19 @@ int GenericSyncer::Sync(const SyncParma ¶m) { int errCode = SyncParamCheck(param); if (errCode != E_OK) { + LOGE("[Syncer] SyncParamCheck failed err=%d", errCode); return errCode; } errCode = AddQueuedManualSyncSize(param.mode, param.wait); if (errCode != E_OK) { + LOGE("[Syncer] AddQueuedManualSyncSize failed err=%d", errCode); return errCode; } uint32_t syncId = GenerateSyncId(); errCode = PrepareSync(param, syncId); if (errCode != E_OK) { - LOGE("[Syncer] PrepareSync failed when sync called, err %d", errCode); + LOGE("[Syncer] PrepareSync failed when sync called, err=%d", errCode); return errCode; } PerformanceAnalysis::GetInstance()->StepTimeRecordEnd(PT_TEST_RECORDS::RECORD_SYNC_TOTAL); @@ -209,6 +213,7 @@ int GenericSyncer::PrepareSync(const SyncParma ¶m, uint32_t syncId) auto *operation = new (std::nothrow) SyncOperation(syncId, param.devices, param.mode, param.onComplete, param.wait); if (operation == nullptr) { + LOGE("[Syncer] operation is nullptr"); SubQueuedSyncSize(); return -E_OUT_OF_MEMORY; } @@ -242,7 +247,7 @@ int GenericSyncer::RemoveSyncOperation(int syncId) std::unique_lock lock(operationMapLock_); auto iter = syncOperationMap_.find(syncId); if (iter != syncOperationMap_.end()) { - LOGD("[Syncer] RemoveSyncOperation id:%d.", syncId); + LOGD("[Syncer] RemoveSyncOperation id=%d.", syncId); operation = iter->second; syncOperationMap_.erase(syncId); lock.unlock(); @@ -275,6 +280,7 @@ int GenericSyncer::StopSync() uint64_t GenericSyncer::GetTimeStamp() { if (timeHelper_ == nullptr) { + LOGD("[Syncer] timeHelper_ is nullptr."); return TimeHelper::GetSysCurrentTime(); } return timeHelper_->GetTime(); @@ -288,6 +294,7 @@ void GenericSyncer::QueryAutoSync(const InternalSyncParma ¶m) void GenericSyncer::AddSyncOperation(SyncOperation *operation) { if (operation == nullptr) { + LOGD("[Syncer] operation is nullptr."); return; } @@ -326,7 +333,7 @@ int GenericSyncer::InitMetaData(ISyncInterface *syncInterface) metadata_ = std::make_shared(); int errCode = metadata_->Initialize(syncInterface); if (errCode != E_OK) { - LOGE("[Syncer] metadata Initializeate failed! err %d.", errCode); + LOGE("[Syncer] metadata Initializeate failed! err=%d.", errCode); metadata_ = nullptr; } return errCode; @@ -341,7 +348,7 @@ int GenericSyncer::InitTimeHelper(ISyncInterface *syncInterface) timeHelper_ = std::make_shared(); int errCode = timeHelper_->Initialize(syncInterface, metadata_); if (errCode != E_OK) { - LOGE("[Syncer] TimeHelper init failed! err:%d.", errCode); + LOGE("[Syncer] TimeHelper init failed! err=%d.", errCode); timeHelper_ = nullptr; } return errCode; @@ -355,6 +362,7 @@ int GenericSyncer::InitSyncEngine(ISyncInterface *syncInterface) } int errCode = BuildSyncEngine(); if (errCode != E_OK) { + LOGE("[Syncer] BuildSyncEngine failed! err=%d.", errCode); return errCode; } const std::function onlineFunc = std::bind(&GenericSyncer::RemoteDataChanged, @@ -370,7 +378,7 @@ int GenericSyncer::InitSyncEngine(ISyncInterface *syncInterface) label_ = syncEngine_->GetLabel(); return E_OK; } else { - LOGE("[Syncer] SyncEngine init failed! err:%d.", errCode); + LOGE("[Syncer] SyncEngine init failed! err=%d.", errCode); if (syncEngine_ != nullptr) { RefObject::KillAndDecObjRef(syncEngine_); syncEngine_ = nullptr; @@ -389,6 +397,7 @@ int GenericSyncer::CheckSyncActive(ISyncInterface *syncInterface, bool isNeedAct LOGI("[Syncer] syncer no need to active"); int errCode = BuildSyncEngine(); if (errCode != E_OK) { + LOGE("[Syncer] BuildSyncEngine failed! err=%d.", errCode); return errCode; } return -E_NO_NEED_ACTIVE; @@ -488,6 +497,7 @@ int GenericSyncer::SyncModuleInit() if (!isInit) { int errCode = SyncResourceInit(); if (errCode != E_OK) { + LOGE("[Syncer] SyncResourceInit failed! err=%d.", errCode); return errCode; } isInit = true; @@ -541,33 +551,36 @@ int GenericSyncer::SyncResourceInit() int GenericSyncer::GetQueuedSyncSize(int *queuedSyncSize) const { if (queuedSyncSize == nullptr) { + LOGE("[GenericSyncer] queuedSyncSize is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); *queuedSyncSize = queuedManualSyncSize_; - LOGI("[GenericSyncer] GetQueuedSyncSize:%d", queuedManualSyncSize_); + LOGI("[GenericSyncer] GetQueuedSyncSize=%d", queuedManualSyncSize_); return E_OK; } int GenericSyncer::SetQueuedSyncLimit(const int *queuedSyncLimit) { if (queuedSyncLimit == nullptr) { + LOGE("[GenericSyncer] queuedSyncLimit is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); queuedManualSyncLimit_ = *queuedSyncLimit; - LOGI("[GenericSyncer] SetQueuedSyncLimit:%d", queuedManualSyncLimit_); + LOGI("[GenericSyncer] SetQueuedSyncLimit=%d", queuedManualSyncLimit_); return E_OK; } int GenericSyncer::GetQueuedSyncLimit(int *queuedSyncLimit) const { if (queuedSyncLimit == nullptr) { + LOGE("[GenericSyncer] queuedSyncLimit is nullptr"); return -E_INVALID_ARGS; } std::lock_guard lock(queuedManualSyncLock_); *queuedSyncLimit = queuedManualSyncLimit_; - LOGI("[GenericSyncer] GetQueuedSyncLimit:%d", queuedManualSyncLimit_); + LOGI("[GenericSyncer] GetQueuedSyncLimit=%d", queuedManualSyncLimit_); return E_OK; } @@ -598,15 +611,15 @@ bool GenericSyncer::IsQueuedManualSyncFull(int mode, bool wait) const { std::lock_guard lock(queuedManualSyncLock_); if (IsManualSync(mode) && (!manualSyncEnable_)) { - LOGI("[GenericSyncer] manualSyncEnable_:false"); + LOGI("[GenericSyncer] manualSyncEnable_=false"); return true; } if (IsManualSync(mode) && (!wait)) { if (queuedManualSyncSize_ < queuedManualSyncLimit_) { + LOGD("[GenericSyncer] queuedManualSyncSize_=%d < queuedManualSyncLimit_=%d", queuedManualSyncSize_, + queuedManualSyncLimit_); return false; } else { - LOGD("[GenericSyncer] queuedManualSyncSize_:%d < queuedManualSyncLimit_:%d", queuedManualSyncSize_, - queuedManualSyncLimit_); return true; } } else { @@ -628,7 +641,7 @@ int GenericSyncer::DisableManualSync(void) { std::lock_guard lock(queuedManualSyncLock_); if (queuedManualSyncSize_ > 0) { - LOGD("[GenericSyncer] DisableManualSync fail, queuedManualSyncSize_:%d", queuedManualSyncSize_); + LOGD("[GenericSyncer] DisableManualSync fail, queuedManualSyncSize_=%d", queuedManualSyncSize_); return -E_BUSY; } manualSyncEnable_ = false; @@ -649,7 +662,7 @@ int GenericSyncer::GetLocalIdentity(std::string &outTarget) const std::string deviceId; int errCode = RuntimeContext::GetInstance()->GetLocalIdentity(deviceId); if (errCode != E_OK) { - LOGE("[GenericSyncer] GetLocalIdentity fail errCode:%d", errCode); + LOGE("[GenericSyncer] GetLocalIdentity fail errCode=%d", errCode); return errCode; } outTarget = DBCommon::TransferHashString(deviceId); @@ -688,6 +701,7 @@ void GenericSyncer::GetOnlineDevices(std::vector &devices) const int GenericSyncer::SetSyncRetry(bool isRetry) { if (syncEngine_ == nullptr) { + LOGE("[Syncer] syncEngine_ is nullptr"); return -E_NOT_INIT; } syncEngine_->SetSyncRetry(isRetry); @@ -698,6 +712,7 @@ int GenericSyncer::SetEqualIdentifier(const std::string &identifier, const std:: { std::lock_guard lock(syncerLock_); if (syncEngine_ == nullptr) { + LOGE("[Syncer] syncEngine_ is nullptr"); return -E_NOT_INIT; } int errCode = syncEngine_->SetEqualIdentifier(identifier, targets); @@ -735,9 +750,11 @@ int GenericSyncer::SyncParamCheck(const SyncParma ¶m) const std::lock_guard lock(syncerLock_); int errCode = StatusCheck(); if (errCode != E_OK) { + LOGE("[Syncer] StatusCheck failed err=%d", errCode); return errCode; } if (!IsValidDevices(param.devices) || !IsValidMode(param.mode)) { + LOGE("[Syncer] Validity error"); return -E_INVALID_ARGS; } if (IsQueuedManualSyncFull(param.mode, param.wait)) { @@ -768,6 +785,7 @@ int GenericSyncer::BuildSyncEngine() } syncEngine_ = CreateSyncEngine(); if (syncEngine_ == nullptr) { + LOGE("[Syncer] syncEngine_ is nullptr"); return -E_OUT_OF_MEMORY; } syncEngine_->OnLastRef([this]() { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp index 2ab367bb6..7a9efb790 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/meta_data.cpp @@ -54,9 +54,11 @@ int Metadata::Initialize(ISyncInterface* storage) int errCode = GetMetadataFromDb(key, timeOffset); if (errCode == -E_NOT_FOUND) { - int err = SaveLocalTimeOffset(TimeHelper::BASE_OFFSET); + LOGD("[Metadata][Initialize] GetMetadataFromDb failed errCode=%d", errCode); + uint64_t randTimeOffset = GetRandTimeOffset(); + int err = SaveLocalTimeOffset(TimeHelper::BASE_OFFSET + static_cast(randTimeOffset)); if (err != E_OK) { - LOGD("[Metadata][Initialize]SaveLocalTimeOffset failed errCode:%d", err); + LOGD("[Metadata][Initialize]SaveLocalTimeOffset failed errCode=%d", err); return err; } } else if (errCode == E_OK) { @@ -80,7 +82,7 @@ int Metadata::SaveTimeOffset(const DeviceID &deviceId, TimeOffset inValue) GetMetaDataValue(deviceId, metadata, true); metadata.timeOffset = inValue; metadata.lastUpdateTime = TimeHelper::GetSysCurrentTime(); - LOGD("Metadata::SaveTimeOffset = %lld dev %s", inValue, STR_MASK(deviceId)); + LOGD("Metadata::SaveTimeOffset = %lld dev=%s", inValue, STR_MASK(deviceId)); return SaveMetaDataValue(deviceId, metadata); } @@ -140,7 +142,7 @@ int Metadata::SaveLocalTimeOffset(TimeOffset timeOffset) LOGD("Metadata::SaveLocalTimeOffset offset = %lld", timeOffset); int errCode = SetMetadataToDb(localTimeOffsetValue, timeOffsetValue); if (errCode != E_OK) { - LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode:%d", errCode); + LOGE("Metadata::SaveLocalTimeOffset SetMetadataToDb failed errCode=%d", errCode); } return errCode; } @@ -167,15 +169,15 @@ int Metadata::EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, // peerWaterMark must be erased at last int errCode = SavePeerWaterMark(deviceId, 0, isNeedHash); if (errCode != E_OK) { - LOGE("[Metadata] erase peerWaterMark failed errCode:%d", errCode); + LOGE("[Metadata] erase peerWaterMark failed errCode=%d", errCode); return errCode; } if (errCodeQuerySync != E_OK) { - LOGE("[Metadata] erase queryWaterMark failed errCode:%d", errCodeQuerySync); + LOGE("[Metadata] erase queryWaterMark failed errCode=%d", errCodeQuerySync); return errCodeQuerySync; } if (errCodeDeleteSync != E_OK) { - LOGE("[Metadata] erase deleteWaterMark failed errCode:%d", errCodeDeleteSync); + LOGE("[Metadata] erase deleteWaterMark failed errCode=%d", errCodeDeleteSync); return errCodeDeleteSync; } return E_OK; @@ -200,6 +202,7 @@ int Metadata::SaveMetaDataValue(const DeviceID &deviceId, const MetaDataValue &i std::vector value; int errCode = SerializeMetaData(inValue, value); if (errCode != E_OK) { + LOGE("Metadata::SaveMetaDataValue SerializeMetaData failed errCode=%d", errCode); return errCode; } @@ -209,7 +212,7 @@ int Metadata::SaveMetaDataValue(const DeviceID &deviceId, const MetaDataValue &i DBCommon::StringToVector(hashDeviceId, key); errCode = SetMetadataToDb(key, value); if (errCode != E_OK) { - LOGE("Metadata::SetMetadataToDb failed errCode:%d", errCode); + LOGE("Metadata::SetMetadataToDb failed errCode=%d", errCode); return errCode; } PutMetadataToMap(hashDeviceId, inValue); @@ -249,6 +252,7 @@ int Metadata::DeSerializeMetaData(const std::vector &inValue, MetaDataV int Metadata::GetMetadataFromDb(const std::vector &key, std::vector &outValue) const { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::GetMetadataFromDb naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->GetMetaData(key, outValue); @@ -257,6 +261,7 @@ int Metadata::GetMetadataFromDb(const std::vector &key, std::vector &key, const std::vector &inValue) { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::SetMetadataToDb naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->PutMetaData(key, inValue); @@ -265,6 +270,7 @@ int Metadata::SetMetadataToDb(const std::vector &key, const std::vector int Metadata::DeleteMetaDataFromDB(const std::vector &keys) const { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::DeleteMetaDataFromDB naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->DeleteMetaData(keys); @@ -291,6 +297,7 @@ int64_t Metadata::StringToLong(const std::vector &value) const int Metadata::GetAllMetadataKey(std::vector> &keys) { if (naturalStoragePtr_ == nullptr) { + LOGE("Metadata::GetAllMetadataKey naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->GetAllMetaKeys(keys); @@ -322,15 +329,17 @@ int Metadata::LoadAllMetadata() std::vector> querySyncIds; for (const auto &deviceId : metaDataKeys) { if (IsMetaDataKey(deviceId, DEVICEID_PREFIX_KEY)) { - errCode = LoadDeviceIdDataToMap(deviceId); + int errCode = LoadDeviceIdDataToMap(deviceId); if (errCode != E_OK) { + LOGE("[Metadata] LoadDeviceIdDataToMap failed err=%d", errCode); return errCode; } } else if (IsMetaDataKey(deviceId, QuerySyncWaterMarkHelper::GetQuerySyncPrefixKey())) { querySyncIds.push_back(deviceId); } else if (IsMetaDataKey(deviceId, QuerySyncWaterMarkHelper::GetDeleteSyncPrefixKey())) { - errCode = querySyncWaterMarkHelper_.LoadDeleteSyncDataToCache(deviceId); + int errCode = querySyncWaterMarkHelper_.LoadDeleteSyncDataToCache(deviceId); if (errCode != E_OK) { + LOGE("[Metadata] LoadDeleteSyncDataToCache failed err=%d", errCode); return errCode; } } @@ -343,12 +352,14 @@ int Metadata::LoadDeviceIdDataToMap(const Key &key) std::vector value; int errCode = GetMetadataFromDb(key, value); if (errCode != E_OK) { + LOGE("Metadata::LoadDeviceIdDataToMap GetMetadataFromDb failed err=%d", errCode); return errCode; } MetaDataValue metaValue; std::string metaKey(key.begin(), key.end()); errCode = DeSerializeMetaData(value, metaValue); if (errCode != E_OK) { + LOGE("Metadata::LoadDeviceIdDataToMap DeSerializeMetaData failed err=%d", errCode); return errCode; } std::lock_guard lockGuard(metadataLock_); @@ -389,6 +400,7 @@ int Metadata::GetRecvQueryWaterMark(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetRecvQueryWaterMark GetQueryWaterMark failed err=%d", errCode); return errCode; } WaterMark peerWaterMark; @@ -409,6 +421,7 @@ int Metadata::GetSendQueryWaterMark(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetSendQueryWaterMark GetQueryWaterMark failed err=%d", errCode); return errCode; } if (isAutoLift) { @@ -432,6 +445,7 @@ int Metadata::GetLastQueryTime(const std::string &queryIdentify, const std::stri QueryWaterMark queryWaterMark; int errCode = querySyncWaterMarkHelper_.GetQueryWaterMark(queryIdentify, deviceId, queryWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetLastQueryTime GetQueryWaterMark failed err=%d", errCode); return errCode; } timeStamp = queryWaterMark.lastQueryTime; @@ -449,6 +463,7 @@ int Metadata::GetSendDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &wa DeleteWaterMark deleteWaterMark; int errCode = querySyncWaterMarkHelper_.GetDeleteSyncWaterMark(deviceId, deleteWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetSendDeleteSyncWaterMark GetDeleteSyncWaterMark failed err=%d", errCode); return errCode; } if (isAutoLift) { @@ -471,6 +486,7 @@ int Metadata::GetRecvDeleteSyncWaterMark(const DeviceID &deviceId, WaterMark &wa DeleteWaterMark deleteWaterMark; int errCode = querySyncWaterMarkHelper_.GetDeleteSyncWaterMark(deviceId, deleteWaterMark); if (errCode != E_OK) { + LOGE("Metadata::GetRecvDeleteSyncWaterMark GetDeleteSyncWaterMark failed err=%d", errCode); return errCode; } WaterMark peerWaterMark; @@ -538,6 +554,7 @@ int Metadata::ResetMetaDataAfterRemoveData(const DeviceID &deviceId) metadata.localWaterMark = 0; return SaveMetaDataValue(deviceId, metadata); } + LOGI("Metadata::ResetMetaDataAfterRemoveData hashDeviceId not found"); return -E_NOT_FOUND; } @@ -558,6 +575,7 @@ void Metadata::GetRemoveDataMark(const DeviceID &deviceId, uint64_t &outValue) int Metadata::DeleteMetaDataByPrefixKey(const Key &keyPrefix) const { if (naturalStoragePtr_ == nullptr) { + LOGD("Metadata::DeleteMetaDataByPrefixKey naturalStoragePtr_ is nullptr"); return -E_INVALID_DB; } return naturalStoragePtr_->DeleteMetaDataByPrefixKey(keyPrefix); @@ -572,6 +590,7 @@ uint64_t Metadata::GetQueryLastTimestamp(const DeviceID &deviceId, const std::st int errCode = GetMetadataFromDb(key, value); std::lock_guard lockGuard(metadataLock_); if (errCode == -E_NOT_FOUND) { + LOGI("errCode is -E_NOT_FOUND"); auto iter = queryIdMap_.find(deviceId); if (iter != queryIdMap_.end()) { if (iter->second.find(hashqueryId) == iter->second.end()) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp index 662c6bb3f..483df48d0 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_data_sync.cpp @@ -100,6 +100,7 @@ MultiVerDataSync::~MultiVerDataSync() int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("MultiVerDataSync::Serialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -109,6 +110,7 @@ int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Mess case TYPE_RESPONSE: return AckPacketSerialization(buffer, length, inMsg); default: + LOGE("MultiVerDataSync::Serialization message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -116,6 +118,7 @@ int MultiVerDataSync::Serialization(uint8_t *buffer, uint32_t length, const Mess int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("MultiVerDataSync::DeSerialization buffer is nullptr or packet validity error"); return -E_MESSAGE_ID_ERROR; } @@ -125,6 +128,7 @@ int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Me case TYPE_RESPONSE: return AckPacketDeSerialization(buffer, length, inMsg); default: + LOGE("MultiVerDataSync::DeSerialization message type error"); return -E_MESSAGE_TYPE_ERROR; } } @@ -132,6 +136,7 @@ int MultiVerDataSync::DeSerialization(const uint8_t *buffer, uint32_t length, Me uint32_t MultiVerDataSync::CalculateLen(const Message *inMsg) { if (!(IsPacketValid(inMsg, TYPE_RESPONSE) || IsPacketValid(inMsg, TYPE_REQUEST))) { + LOGE("MultiVerDataSync::CalculateLen packet validity error"); return 0; } @@ -167,6 +172,7 @@ int MultiVerDataSync::RegisterTransformFunc() int MultiVerDataSync::Initialize(MultiVerKvDBSyncInterface *storagePtr, ICommunicator *communicateHandle) { if ((storagePtr == nullptr) || (communicateHandle == nullptr)) { + LOGE("MultiVerDataSync::Initialize storagePtr or communicateHandle is nullptr"); return -E_INVALID_ARGS; } storagePtr_ = storagePtr; @@ -182,6 +188,7 @@ void MultiVerDataSync::TimeOutCallback(MultiVerSyncTaskContext *context, const M int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) { if (context == nullptr) { + LOGE("MultiVerDataSync::SyncStart context is nullptr"); return -E_INVALID_ARGS; } LOGD("MultiVerDataSync::SyncStart dst=%s{private}, begin", context->GetDeviceId().c_str()); @@ -195,6 +202,7 @@ int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_DATA_GET_VALID_COMMIT); } if (errCode != E_OK) { + LOGI("MultiVerDataSync::SyncStart GetValidCommit failed"); // sync don't need start SendFinishedRequest(context); return errCode; @@ -208,18 +216,22 @@ int MultiVerDataSync::SyncStart(MultiVerSyncTaskContext *context) int MultiVerDataSync::RequestRecvCallback(const MultiVerSyncTaskContext *context, const Message *message) { if (message == nullptr || context == nullptr) { + LOGE("MultiVerDataSync::RequestRecvCallback message or context is nullptr"); return -E_INVALID_ARGS; } if (!IsPacketValid(message, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestRecvCallback packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::RequestRecvCallback packet is nullptr"); return -E_INVALID_ARGS; } if (packet->GetErrCode() == -E_LAST_SYNC_FRAME) { + LOGE("MultiVerDataSync::RequestRecvCallback packet errCode equal -E_LAST_SYNC_FRAME"); return -E_LAST_SYNC_FRAME; } MultiVerCommitNode commit; @@ -250,19 +262,23 @@ int MultiVerDataSync::RequestRecvCallback(const MultiVerSyncTaskContext *context int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Message *message) { if (message == nullptr) { + LOGE("MultiVerDataSync::AckRecvCallback message is nullptr"); return -E_INVALID_ARGS; } if (!IsPacketValid(message, TYPE_RESPONSE) || (context == nullptr)) { + LOGE("MultiVerDataSync::AckRecvCallback context is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = message->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::AckRecvCallback packet is nullptr"); return -E_INVALID_ARGS; } int32_t errCode = E_OK; packet->GetErrorCode(errCode); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckRecvCallback packet GetErrorCode=%d", errCode); return errCode; } std::vector> dataEntries; @@ -286,6 +302,7 @@ int MultiVerDataSync::AckRecvCallback(MultiVerSyncTaskContext *context, const Me entry = entries[0]; errCode = entry->GetValueHash(valueHashes); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckRecvCallback entry GetValueHash errCode=%d", errCode); return errCode; } } @@ -316,11 +333,12 @@ void MultiVerDataSync::ReleaseKvEntry(const MultiVerKvEntry *entry) void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *context) { if (context == nullptr) { + LOGE("MultiVerDataSync::SendFinishedRequest context is nullptr"); return; } MultiVerRequestPacket *packet = new (std::nothrow) MultiVerRequestPacket(); if (packet == nullptr) { - LOGE("MultiVerRequestPacket::SendRequestPacket : new packet error"); + LOGE("MultiVerRequestPacket::SendFinishedRequest : new packet error"); return; } packet->SetErrCode(-E_LAST_SYNC_FRAME); @@ -328,7 +346,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex if (message == nullptr) { delete packet; packet = nullptr; - LOGE("MultiVerDataSync::SendRequestPacket : new message error"); + LOGE("MultiVerDataSync::SendFinishedRequest : new message error"); return; } message->SetMessageType(TYPE_REQUEST); @@ -339,7 +357,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex packet = nullptr; delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendFinishedRequest] : SetExternalObject failed errCode:%d", errCode); + LOGE("[MultiVerDataSync][SendFinishedRequest] : SetExternalObject failed errCode=%d", errCode); return; } message->SetSessionId(context->GetRequestSessionId()); @@ -349,7 +367,7 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex if (errCode != E_OK) { delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest failed, err %d", errCode); + LOGE("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest failed, err=%d", errCode); } LOGI("[MultiVerDataSync][SendFinishedRequest] SendFinishedRequest dst=%s{private}", context->GetDeviceId().c_str()); } @@ -357,10 +375,12 @@ void MultiVerDataSync::SendFinishedRequest(const MultiVerSyncTaskContext *contex int MultiVerDataSync::RequestPacketCalculateLen(const Message *inMsg, uint32_t &len) { if ((inMsg == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestPacketCalculateLen inMsg is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::RequestPacketCalculateLen packet is nullptr"); return -E_INVALID_ARGS; } @@ -371,10 +391,12 @@ int MultiVerDataSync::RequestPacketCalculateLen(const Message *inMsg, uint32_t & int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestPacketSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerRequestPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("MultiVerDataSync::RequestPacketSerialization packet is nullptr"); return -E_INVALID_ARGS; } @@ -385,6 +407,7 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt Parcel parcel(buffer, length); int errCode = parcel.WriteInt(ackCode); if (errCode != E_OK) { + LOGE("MultiVerDataSync::RequestPacketSerialization parcel write ackCode error=%d", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -392,6 +415,7 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt // commitMap Serialization errCode = parcel.WriteMultiVerCommit(commit); if (errCode != E_OK) { + LOGE("MultiVerDataSync::RequestPacketSerialization parcel write commit error=%d", errCode); return -E_SECUREC_ERROR; } @@ -401,6 +425,7 @@ int MultiVerDataSync::RequestPacketSerialization(uint8_t *buffer, uint32_t lengt int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_REQUEST)) { + LOGE("MultiVerDataSync::RequestPacketDeSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -409,6 +434,7 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 int32_t pktErrCode; uint64_t packLen = parcel.ReadInt(pktErrCode); if (parcel.IsError()) { + LOGE("MultiVerDataSync::RequestPacketDeSerialization parcel error"); return -E_INVALID_ARGS; } parcel.EightByteAlign(); @@ -416,6 +442,7 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 // commit DeSerialization packLen += parcel.ReadMultiVerCommit(commit); if (packLen != length || parcel.IsError()) { + LOGE("MultiVerDataSync::RequestPacketDeSerialization parcel length=%llu error", packLen); return -E_INVALID_ARGS; } MultiVerRequestPacket *packet = new (std::nothrow) MultiVerRequestPacket(); @@ -436,11 +463,13 @@ int MultiVerDataSync::RequestPacketDeSerialization(const uint8_t *buffer, uint32 int MultiVerDataSync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) { if (!IsPacketValid(inMsg, TYPE_RESPONSE)) { + LOGE("MultiVerDataSync::AckPacketCalculateLen packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = inMsg->GetObject(); if (packet == nullptr) { + LOGE("MultiVerDataSync::AckPacketCalculateLen packet is nullptr"); return -E_INVALID_ARGS; } len = packet->CalculateLen(); @@ -450,10 +479,12 @@ int MultiVerDataSync::AckPacketCalculateLen(const Message *inMsg, uint32_t &len) int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, const Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_RESPONSE)) { + LOGE("MultiVerDataSync::AckPacketSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } const MultiVerAckPacket *packet = inMsg->GetObject(); if ((packet == nullptr) || (length != packet->CalculateLen())) { + LOGE("MultiVerDataSync::AckPacketSerialization packet length=%llu error or packet is nullptr", length); return -E_INVALID_ARGS; } @@ -466,6 +497,7 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c // errCode Serialization errCode = parcel.WriteInt(errCode); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckPacketSerialization packet get errorCode=%d", errCode); return -E_SECUREC_ERROR; } parcel.EightByteAlign(); @@ -474,6 +506,7 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c for (const auto &iter : entries) { errCode = parcel.WriteVectorChar(iter); if (errCode != E_OK) { + LOGE("MultiVerDataSync::AckPacketSerialization write entry errorCode=%d", errCode); return -E_SECUREC_ERROR; } } @@ -484,6 +517,7 @@ int MultiVerDataSync::AckPacketSerialization(uint8_t *buffer, uint32_t length, c int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t length, Message *inMsg) { if ((buffer == nullptr) || !IsPacketValid(inMsg, TYPE_RESPONSE)) { + LOGE("MultiVerDataSync::AckPacketDeSerialization buffer is nullptr or packet validity error"); return -E_INVALID_ARGS; } @@ -493,6 +527,7 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l // errCode DeSerialization uint32_t packLen = parcel.ReadInt(pktErrCode); if (parcel.IsError()) { + LOGE("MultiVerDataSync::AckPacketDeSerialization parcel read error"); return -E_INVALID_ARGS; } parcel.EightByteAlign(); @@ -506,6 +541,7 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l // A valid dataItem got, Save to storage entries.push_back(data); if (parcel.IsError()) { + LOGE("MultiVerDataSync::AckPacketDeSerialization parcel read entry error"); return -E_INVALID_ARGS; } } @@ -527,6 +563,7 @@ int MultiVerDataSync::AckPacketDeSerialization(const uint8_t *buffer, uint32_t l bool MultiVerDataSync::IsPacketValid(const Message *inMsg, uint16_t messageType) { if ((inMsg == nullptr) || (inMsg->GetMessageId() != MULTI_VER_DATA_SYNC_MESSAGE)) { + LOGE("MultiVerDataSync::AckPacketDeSerialization inMsg is nullptr or get message error"); return false; } if (messageType != inMsg->GetMessageType()) { @@ -576,7 +613,7 @@ bool MultiVerDataSync::IsCommitExisted(const MultiVerCommitNode &commit) int MultiVerDataSync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("MultiVerDataSync::Send ERR! ERR = %d", errCode); @@ -607,7 +644,7 @@ int MultiVerDataSync::SendRequestPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete message; message = nullptr; - LOGE("[MultiVerDataSync][SendRequestPacket] : SetExternalObject failed errCode:%d", errCode); + LOGE("[MultiVerDataSync][SendRequestPacket] : SetExternalObject failed errCode=%d", errCode); return errCode; } message->SetSessionId(context->GetRequestSessionId()); @@ -664,7 +701,7 @@ int MultiVerDataSync::SendAckPacket(const MultiVerSyncTaskContext *context, packet = nullptr; delete ackMessage; ackMessage = nullptr; - LOGE("[MultiVerDataSync][SendAckPacket] : SetExternalObject failed errCode:%d", errCode); + LOGE("[MultiVerDataSync][SendAckPacket] : SetExternalObject failed errCode=%d", errCode); return errCode; } ackMessage->SetSequenceId(message->GetSequenceId()); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp index 8e7fe90a5..af46b4a6c 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_state_machine.cpp @@ -62,10 +62,12 @@ int MultiVerSyncStateMachine::Initialize(ISyncTaskContext *context, ISyncInterfa std::shared_ptr &metadata, ICommunicator *communicator) { if (context == nullptr || syncInterface == nullptr || metadata == nullptr || communicator == nullptr) { + LOGE("MultiVerSyncStateMachine::Initialize args is nullptr"); return -E_INVALID_ARGS; } int errCode = SyncStateMachine::Initialize(context, syncInterface, metadata, communicator); if (errCode != E_OK) { + LOGE("MultiVerSyncStateMachine::Initialize Initialize error=%d", errCode); return errCode; } @@ -76,10 +78,9 @@ int MultiVerSyncStateMachine::Initialize(ISyncTaskContext *context, ISyncInterfa errCode = timeSync_->Initialize(communicator, metadata, syncInterface, context->GetDeviceId()); if (errCode != E_OK) { - LOGE("timeSync_->Initialize failed err %d", errCode); + LOGE("MultiVerSyncStateMachine::Initialize timeSync_->Initialize failed err=%d", errCode); goto ERROR_OUT; } - LOGD("timeSync_->Initialize OK"); // init functions below will never fail multiVerStorage_ = static_cast(syncInterface); @@ -104,7 +105,7 @@ void MultiVerSyncStateMachine::SyncStep() int errCode = RuntimeContext::GetInstance()->ScheduleTask( std::bind(&MultiVerSyncStateMachine::SyncStepInnerLocked, this)); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] Schedule SyncStep failed"); + LOGE("[MultiVerSyncStateMachine] Schedule SyncStep failed errCode=%d", errCode); RefObject::DecObjRef(communicator_); RefObject::DecObjRef(context_); } @@ -123,16 +124,18 @@ int MultiVerSyncStateMachine::MessageCallbackCheck(const Message *inMsg) { RefObject::AutoLock lock(context_); if (context_->IsKilled()) { + LOGE("MultiVerSyncStateMachine::MessageCallbackCheck context is killed"); return -E_OBJ_IS_KILLED; } if (!IsPacketValid(inMsg)) { + LOGE("MultiVerSyncStateMachine::MessageCallbackCheck packet validity error"); return -E_INVALID_ARGS; } if ((inMsg->GetMessageType() == TYPE_RESPONSE) && (inMsg->GetMessageId() != TIME_SYNC_MESSAGE)) { context_->IncSequenceId(); int errCode = ResetWatchDog(); if (errCode != E_OK) { - LOGW("[MultiVerSyncStateMachine][MessageCallback] ResetWatchDog failed , err %d", errCode); + LOGW("[MultiVerSyncStateMachine][MessageCallback] ResetWatchDog failed , err=%d", errCode); } } return E_OK; @@ -141,6 +144,7 @@ int MultiVerSyncStateMachine::MessageCallbackCheck(const Message *inMsg) int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) { if (inMsg == nullptr) { + LOGE("MultiVerSyncStateMachine::ReceiveMessageCallback inMsg is nullptr"); return -E_INVALID_ARGS; } if (inMsg->IsFeedbackError()) { @@ -148,11 +152,13 @@ int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) return -static_cast(inMsg->GetErrorNo()); } if (inMsg->GetMessageId() == TIME_SYNC_MESSAGE) { + LOGD("MultiVerSyncStateMachine::ReceiveMessageCallback messageid is time sync"); return TimeSyncPacketRecvCallback(context_, inMsg); } std::lock_guard lock(stateMachineLock_); int errCode = MessageCallbackCheck(inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine] MessageCallbackCheck error=%d", errCode); return errCode; } switch (inMsg->GetMessageId()) { @@ -173,6 +179,7 @@ int MultiVerSyncStateMachine::ReceiveMessageCallback(Message *inMsg) break; } if (errCode == -E_LAST_SYNC_FRAME) { + LOGE("[MultiVerSyncStateMachine] errCode is -E_LAST_SYNC_FRAME"); SyncResponseEnd(inMsg->GetSessionId()); return errCode; } @@ -199,7 +206,7 @@ int MultiVerSyncStateMachine::CommitHistorySyncStepInner(void) { int errCode = commitHistorySync_->SyncStart(context_); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][CommitHistorySyncStep] failed, errCode %d", errCode); + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncStep] failed, errCode=%d", errCode); } return errCode; } @@ -243,6 +250,8 @@ void MultiVerSyncStateMachine::SyncStepInnerLocked() if (errCode == -E_NOT_FOUND) { int err = OneCommitSyncFinish(); if (err != E_OK) { + LOGD("[MultiVerSyncStateMachine][SyncStepInnerLocked] OneCommitSyncFinish failed" + ", error=%d", err); valueSliceSync_->SendFinishedRequest(context_); Abort(); goto SYNC_STEP_SAFE_OUT; @@ -279,7 +288,7 @@ int MultiVerSyncStateMachine::StartSyncInner() } int errCode = StartWatchDog(); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][StartSync] WatchDog start failed! err:%d", errCode); + LOGE("[MultiVerSyncStateMachine][StartSync] WatchDog start failed! err=%d", errCode); return errCode; } SyncStep(); @@ -318,6 +327,7 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC { int errCode; if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != TIME_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][TimeSyncPacketRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } switch (inMsg->GetMessageType()) { @@ -327,7 +337,7 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC case TYPE_RESPONSE: errCode = timeSync_->AckRecv(inMsg); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine] TimeSyncPacketRecvCallback AckRecv failed err %d", errCode); + LOGE("[MultiVerSyncStateMachine] TimeSyncPacketRecvCallback AckRecv failed err=%d", errCode); } return errCode; default: @@ -338,10 +348,12 @@ int MultiVerSyncStateMachine::TimeSyncPacketRecvCallback(const MultiVerSyncTaskC int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != COMMIT_HISTORY_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; + LOGD("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: if (performance != nullptr) { @@ -354,6 +366,7 @@ int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskC } errCode = commitHistorySync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine][CommitHistorySyncPktRecvCallback] AckRecvCallback error=%d", errCode); return errCode; } currentState_ = MULTI_VER_DATA_ENTRY_SYNC; @@ -367,10 +380,12 @@ int MultiVerSyncStateMachine::CommitHistorySyncPktRecvCallback(MultiVerSyncTaskC int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != MULTI_VER_DATA_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; + LOGD("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: return multiVerDataSync_->RequestRecvCallback(context, inMsg); @@ -380,6 +395,7 @@ int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContex } errCode = multiVerDataSync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine][MultiVerDataPktRecvCallback] AckRecvCallback error=%d", errCode); multiVerDataSync_->SendFinishedRequest(context); return errCode; } @@ -394,10 +410,12 @@ int MultiVerSyncStateMachine::MultiVerDataPktRecvCallback(MultiVerSyncTaskContex int MultiVerSyncStateMachine::ValueSlicePktRecvCallback(MultiVerSyncTaskContext *context, const Message *inMsg) { if ((context == nullptr) || (inMsg == nullptr) || (inMsg->GetMessageId() != VALUE_SLICE_SYNC_MESSAGE)) { + LOGE("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] args is nullptr"); return -E_INVALID_ARGS; } PerformanceAnalysis *performance = PerformanceAnalysis::GetInstance(); int errCode; + LOGD("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] message type=%d", inMsg->GetMessageType()); switch (inMsg->GetMessageType()) { case TYPE_REQUEST: return valueSliceSync_->RequestRecvCallback(context, inMsg); @@ -407,6 +425,7 @@ int MultiVerSyncStateMachine::ValueSlicePktRecvCallback(MultiVerSyncTaskContext } errCode = valueSliceSync_->AckRecvCallback(context, inMsg); if (errCode != E_OK) { + LOGE("[MultiVerSyncStateMachine][ValueSlicePktRecvCallback] AckRecvCallback error=%d", errCode); valueSliceSync_->SendFinishedRequest(context); return errCode; } @@ -432,7 +451,7 @@ void MultiVerSyncStateMachine::Finish() performance->StepTimeRecordStart(MV_TEST_RECORDS::RECORD_MERGE); } int errCode = multiVerDataSync_->MergeSyncCommit(commit, commits); - LOGD("MultiVerSyncStateMachine::Finish merge src=%s, MergeSyncCommit errCode:%d", + LOGD("MultiVerSyncStateMachine::Finish merge src=%s, MergeSyncCommit errCode=%d", STR_MASK(context_->GetDeviceId()), errCode); if (performance != nullptr) { performance->StepTimeRecordEnd(MV_TEST_RECORDS::RECORD_MERGE); @@ -463,7 +482,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() STR_MASK(context_->GetDeviceId()), entries.size()); errCode = timeSync_->GetTimeOffset(outOffset, TIME_SYNC_WAIT_TIME); if (errCode != E_OK) { - LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset fail errCode:%d", errCode); + LOGI("MultiVerSyncStateMachine::OneCommitSyncFinish GetTimeOffset failed errCode=%d", errCode); return errCode; } TimeStamp currentLocalTime = context_->GetCurrentLocalTime(); @@ -497,6 +516,7 @@ int MultiVerSyncStateMachine::OneCommitSyncFinish() bool MultiVerSyncStateMachine::IsPacketValid(const Message *inMsg) const { if (inMsg == nullptr) { + LOGE("[MultiVerSyncStateMachine][IsPacketValid] inMsg is nullptr"); return false; } @@ -551,12 +571,12 @@ void MultiVerSyncStateMachine::SyncResponseBegin(uint32_t sessionId) [this]() { int ret = RuntimeContext::GetInstance()->ScheduleTask([this](){ RefObject::DecObjRef(context_); }); if (ret != E_OK) { - LOGE("[MultiVerSyncStateMachine][SyncResponseEnd] timer finalizer ScheduleTask, errCode %d", ret); + LOGE("[MultiVerSyncStateMachine][SyncResponseEnd] timer finalizer ScheduleTask, errCode=%d", ret); } }, timerId); if (errCode != E_OK) { - LOGE("[MultiVerSyncStateMachine][ResponseSessionBegin] SetTimer failed err %d", errCode); + LOGE("[MultiVerSyncStateMachine][ResponseSessionBegin] SetTimer failed err=%d", errCode); RefObject::DecObjRef(context_); return; } @@ -575,7 +595,7 @@ void MultiVerSyncStateMachine::SyncResponseEnd(uint32_t sessionId) return info.sessionId == sessionId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseEnd] Can't find sync response %d", sessionId); + LOGW("[MultiVerSyncStateMachine][SyncResponseEnd] Can't find sync response=%d", sessionId); return; } RuntimeContext::GetInstance()->RemoveTimer(iter->timerId); @@ -594,7 +614,7 @@ int MultiVerSyncStateMachine::SyncResponseTimeout(TimerId timerId) return info.timerId == timerId; }); if (iter == responseInfos_.end()) { - LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId %d", timerId); + LOGW("[MultiVerSyncStateMachine][SyncResponseTimeout] Can't find sync response timerId=%d", timerId); return E_OK; } sessionId = iter->sessionId; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp index 96599edac..2a5ed2ce1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_sync_task_context.cpp @@ -30,6 +30,7 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf std::shared_ptr &metadata, ICommunicator *communicator) { if (deviceId.empty() || (syncInterface == nullptr) || (communicator == nullptr)) { + LOGE("[MultiVerSyncTaskContext][Initialize] args is nullptr."); return -E_INVALID_ARGS; } syncInterface_ = syncInterface; @@ -40,12 +41,13 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf timeHelper_ = std::make_unique(); int errCode = timeHelper_->Initialize(syncInterface, metadata); if (errCode != E_OK) { - LOGE("[MultiVerSyncTaskContext] timeHelper Initialize failed, err %d.", errCode); + LOGE("[MultiVerSyncTaskContext][Initialize] timeHelper Initialize failed, err=%d.", errCode); return errCode; } stateMachine_ = new (std::nothrow) MultiVerSyncStateMachine; if (stateMachine_ == nullptr) { + LOGE("[MultiVerSyncTaskContext][Initialize] stateMachine_ is nullptr."); return -E_OUT_OF_MEMORY; } @@ -65,6 +67,7 @@ int MultiVerSyncTaskContext::Initialize(const std::string &deviceId, ISyncInterf int MultiVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) { if (operation == nullptr) { + LOGE("[MultiVerSyncTaskContext][AddSyncOperation] operation is nullptr"); return -E_INVALID_ARGS; } @@ -76,6 +79,7 @@ int MultiVerSyncTaskContext::AddSyncOperation(SyncOperation *operation) MultiVerSyncTarget *target = new (std::nothrow) MultiVerSyncTarget; if (target == nullptr) { + LOGE("[MultiVerSyncTaskContext][AddSyncOperation] target is nullptr"); return -E_OUT_OF_MEMORY; } target->SetSyncOperation(operation); diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp index 65ac108a1..1167508c0 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/multi_ver_syncer.cpp @@ -36,7 +36,7 @@ MultiVerSyncer::~MultiVerSyncer() void MultiVerSyncer::EnableAutoSync(bool enable) { - LOGD("[Syncer] EnableAutoSync enable = %d", enable); + LOGD("[Syncer] EnableAutoSync enable = %d, autoSyncEnable_ = %d", enable, autoSyncEnable_); if (autoSyncEnable_ == enable) { return; } @@ -49,12 +49,13 @@ void MultiVerSyncer::EnableAutoSync(bool enable) std::vector devices; GetOnlineDevices(devices); if (devices.empty()) { + LOGD("[Syncer] devices is empty"); return; } int errCode = Sync(devices, SyncModeType::AUTO_PULL, nullptr, nullptr, false); if (errCode != E_OK) { - LOGE("[Syncer] sync start by EnableAutoSync failed err %d", errCode); + LOGE("[Syncer] sync start by EnableAutoSync failed err=%d", errCode); } } @@ -85,13 +86,13 @@ void MultiVerSyncer::LocalDataChanged(int notifyEvent) void MultiVerSyncer::RemoteDataChanged(const std::string &device) { - LOGD("[MultiVerSyncer] Remote data changed or device online dev %s{private}", device.c_str()); + LOGD("[MultiVerSyncer] Remote data changed or device online dev=%s{private}", device.c_str()); if (autoSyncEnable_) { std::vector devices; devices.push_back(device); int errCode = Sync(devices, SyncModeType::AUTO_PULL, nullptr, nullptr, false); if (errCode != E_OK) { - LOGE("[MultiVerSyncer] sync start by RemoteDataChanged failed err %d", errCode); + LOGE("[MultiVerSyncer] sync start by RemoteDataChanged failed err=%d", errCode); } } } diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp index 3a6a5cc65..19305a518 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/query_sync_water_mark_helper.cpp @@ -58,6 +58,7 @@ int LruMap::Get(const std::string &key, QueryWaterMark &outValue) { std::lock_guard autoLock(lruLock_); if (cache_.count(key) == 0) { + LOGE("[Meta]Get count key is zero"); return -E_NOT_FOUND; } outValue = cache_[key]; @@ -103,6 +104,7 @@ int LruMap::Elimination(const std::string &key, const QueryWaterMark &inQueryWat int QuerySyncWaterMarkHelper::GetMetadataFromDb(const std::vector &key, std::vector &outValue) { if (storage_ == nullptr) { + LOGE("[Meta]GetMetadataFromDb storage_ is nullptr"); return -E_INVALID_DB; } return storage_->GetMetaData(key, outValue); @@ -111,6 +113,7 @@ int QuerySyncWaterMarkHelper::GetMetadataFromDb(const std::vector &key, int QuerySyncWaterMarkHelper::SetMetadataToDb(const std::vector &key, const std::vector &inValue) { if (storage_ == nullptr) { + LOGE("[Meta]SetMetadataToDb storage_ is nullptr"); return -E_INVALID_DB; } return storage_->PutMetaData(key, inValue); @@ -119,6 +122,7 @@ int QuerySyncWaterMarkHelper::SetMetadataToDb(const std::vector &key, c int QuerySyncWaterMarkHelper::DeleteMetaDataFromDB(const std::vector &keys) const { if (storage_ == nullptr) { + LOGE("[Meta]DeleteMetaDataFromDB storage_ is nullptr"); return -E_INVALID_DB; } return storage_->DeleteMetaData(keys); @@ -135,12 +139,14 @@ int QuerySyncWaterMarkHelper::LoadDeleteSyncDataToCache(const Key &deleteWaterMa std::vector value; int errCode = GetMetadataFromDb(deleteWaterMarkKey, value); if (errCode != E_OK) { + LOGE("[Meta]LoadDeleteSyncDataToCache GetMetadataFromDb error, errCode=%d", errCode); return errCode; } DeleteWaterMark deleteWaterMark; std::string dbKey(deleteWaterMarkKey.begin(), deleteWaterMarkKey.end()); errCode = DeSerializeDeleteWaterMark(value, deleteWaterMark); if (errCode != E_OK) { + LOGE("[Meta]LoadDeleteSyncDataToCache DeSerializeDeleteWaterMark error, errCode=%d", errCode); return errCode; } std::lock_guard autoLock(deleteSyncLock_); @@ -153,6 +159,7 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkInCacheAndDb(const std::string &c { // first get from cache_ int errCode = querySyncCache_.Get(cacheKey, queryWaterMark); + LOGD("[Meta]GetQueryWaterMark get code=%d", errCode); bool addToCache = false; if (errCode == -E_NOT_FOUND) { // second get from db @@ -165,7 +172,6 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkInCacheAndDb(const std::string &c } // something error return if (errCode != E_OK) { - LOGE("[Meta]GetQueryWaterMark Fail code = %d", errCode); return errCode; } // remember add to cache_ @@ -202,6 +208,7 @@ int QuerySyncWaterMarkHelper::SetLastQueryTime(const std::string &queryIdentify, QueryWaterMark queryWaterMark; int errCode = GetQueryWaterMarkInCacheAndDb(cacheKey, queryWaterMark); if (errCode != E_OK) { + LOGE("[Meta]SetLastQueryTime GetQueryWaterMark error, errCode=%d", errCode); return errCode; } queryWaterMark.lastQueryTime = timeStamp; @@ -214,6 +221,7 @@ int QuerySyncWaterMarkHelper::SetRecvQueryWaterMarkWithoutLock(const std::string QueryWaterMark queryWaterMark; int errCode = GetQueryWaterMarkInCacheAndDb(cacheKey, queryWaterMark); if (errCode != E_OK) { + LOGE("[Meta]SetRecvQueryWaterMarkWithoutLock GetQueryWaterMark error, errCode=%d", errCode); return errCode; } queryWaterMark.recvWaterMark = waterMark; @@ -241,6 +249,7 @@ int QuerySyncWaterMarkHelper::UpdateCacheAndSave(const std::string &cacheKey, // update lastUsedTime int errCode = OS::GetCurrentSysTimeInMicrosecond(queryWaterMark.lastUsedTime); if (errCode != E_OK) { + LOGE("[Meta]UpdateCacheAndSave GetCurrentSysTimeInMicrosecond failed, errCode=%d", errCode); return errCode; } // save db first @@ -256,6 +265,7 @@ int QuerySyncWaterMarkHelper::PutQueryWaterMarkToDB(const DeviceID &dbKeyString, { int errCode = OS::GetCurrentSysTimeInMicrosecond(queryWaterMark.lastUsedTime); if (errCode != E_OK) { + LOGE("[Meta]PutQueryWaterMarkToDB GetCurrentSysTimeInMicrosecond failed, errCode=%d", errCode); return errCode; } queryWaterMark.version = QUERY_WATERMARK_VERSION_CURRENT; @@ -268,6 +278,7 @@ int QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB(const DeviceID &dbKeyString Value dbValue; int errCode = SerializeQueryWaterMark(queryWaterMark, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB SerializeQueryWaterMark failed errCode=%d", errCode); return errCode; } // serialize key @@ -276,7 +287,7 @@ int QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB(const DeviceID &dbKeyString // save errCode = SetMetadataToDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB failed errCode:%d", errCode); + LOGE("QuerySyncWaterMarkHelper::SaveQueryWaterMarkToDB SetMetadataToDb failed errCode=%d", errCode); } return errCode; } @@ -290,6 +301,7 @@ int QuerySyncWaterMarkHelper::GetQueryWaterMarkFromDB(const DeviceID &dbKeyStrin Value dbValue; int errCode = GetMetadataFromDb(dbKey, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::GetQueryWaterMarkFromDB GetMetadataFromDb failed errCode=%d", errCode); return errCode; } return DeSerializeQueryWaterMark(dbValue, queryWaterMark); @@ -434,6 +446,7 @@ int QuerySyncWaterMarkHelper::GetDeleteWaterMarkFromDB(const DeviceID &hashDevic Value dbValue; int errCode = GetMetadataFromDb(dbKey, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::GetDeleteWaterMarkFromDB GetMetadataFromDb failed errCode=%d", errCode); return errCode; } // serialize value @@ -447,6 +460,7 @@ int QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB(const DeviceID &hashDevice Value dbValue; int errCode = SerializeDeleteWaterMark(deleteWaterMark, dbValue); if (errCode != E_OK) { + LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB SerializeDeleteWaterMark failed errCode=%d", errCode); return errCode; } Key dbKey; @@ -454,7 +468,7 @@ int QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB(const DeviceID &hashDevice // save errCode = SetMetadataToDb(dbKey, dbValue); if (errCode != E_OK) { - LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB failed errCode:%d", errCode); + LOGE("QuerySyncWaterMarkHelper::SaveDeleteWaterMarkToDB failed errCode=%d", errCode); } return errCode; } @@ -584,7 +598,7 @@ int QuerySyncWaterMarkHelper::ResetRecvQueryWaterMark(const DeviceID &deviceId, DBCommon::StringToVector(prefixKeyStr, prefixKey); int errCode = storage_->DeleteMetaDataByPrefixKey(prefixKey); if (errCode != E_OK) { - LOGE("[META]ResetRecvQueryWaterMark fail errCode:%d", errCode); + LOGE("[META]ResetRecvQueryWaterMark fail errCode=%d", errCode); return errCode; } // clean cache diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp index 2157f5065..4127be1fa 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_message_schedule.cpp @@ -35,6 +35,7 @@ void SingleVerDataMessageSchedule::Initialize(const std::string &label, const st void SingleVerDataMessageSchedule::PutMsg(Message *inMsg) { if (inMsg == nullptr) { + LOGE("[DataMsgSchedule] inMsg is nullptr"); return; } std::lock_guard lock(queueLock_); @@ -69,7 +70,6 @@ Message *SingleVerDataMessageSchedule::MoveNextMsg(SingleVerSyncTaskContext *con Message *msg = GetMsgFromMap(isNeedHandle); isNeedContinue = true; if (msg == nullptr) { - StopTimer(); std::lock_guard lock(workingLock_); isWorking_ = false; return nullptr; diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp index 0b52e0528..3958e63a1 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/single_ver_data_packet.cpp @@ -166,6 +166,7 @@ uint32_t DataRequestPacket::CalculateLen(uint32_t messageId) const } totalLen = Parcel::GetEightByteAlign(totalLen); // 8-byte align if (totalLen > INT32_MAX) { + LOGE("[DataRequestPacket][CalculateLen] Parcel GetEightByteAlign > INT32_MAX"); return 0; } if (messageId == QUERY_SYNC_MESSAGE) { diff --git a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp index 8946b09c7..f6e9ecce9 100644 --- a/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp +++ b/services/distributeddataservice/libs/distributeddb/syncer/src/value_slice_sync.cpp @@ -521,7 +521,7 @@ int ValueSliceSync::GetValidValueSliceHashNode(MultiVerSyncTaskContext *context, int ValueSliceSync::Send(const DeviceID &deviceId, const Message *inMsg) { - SendConfig conf = {false, false, SEND_TIME_OUT, {}}; + SendConfig conf = {false, false, SEND_TIME_OUT}; int errCode = communicateHandle_->SendMessage(deviceId, inMsg, conf); if (errCode != E_OK) { LOGE("ValueSliceSync::Send ERR! err = %d", errCode); diff --git a/services/distributeddataservice/service/kv/user_delegate.cpp b/services/distributeddataservice/service/kv/user_delegate.cpp index 3f35b4ed8..d8055cbef 100644 --- a/services/distributeddataservice/service/kv/user_delegate.cpp +++ b/services/distributeddataservice/service/kv/user_delegate.cpp @@ -58,7 +58,7 @@ std::vector UserDelegate::GetUsers(const std::string &deviceId) for (const auto &entry : deviceUserMap_[deviceId]) { userStatus.emplace_back(entry.first, entry.second); } - ZLOGI("device:%{public}.10s, users:%{public}s", deviceId.c_str(), Serializable::Marshall(userStatus).c_str()); + ZLOGI("device=%{public}.10s, users=%{public}s", deviceId.c_str(), Serializable::Marshall(userStatus).c_str()); return userStatus; } @@ -69,7 +69,7 @@ void UserDelegate::DeleteUsers(const std::string &deviceId) void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector &userStatus) { - ZLOGI("begin, device:%{public}.10s, users:%{public}u", deviceId.c_str(), userStatus.size()); + ZLOGI("begin, device=%{public}.10s, users=%{public}u", deviceId.c_str(), userStatus.size()); deviceUserMap_.ComputeIfPresent(deviceId, [](const auto &key, std::map &userMap) { for (auto &user : userMap) { user.second = false; @@ -78,7 +78,7 @@ void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector osAccountIds = { { 0, true } }; // system user default auto ret = OsAccountManager::QueryActiveOsAccountIds(osAccountIds); if (ret != 0 || osAccountIds.empty()) { - ZLOGE("failed to query os accounts, ret:%{public}d", ret); + ZLOGE("failed to query os accounts, ret=%{public}d", ret); return false; } std::vector userStatus = { { 0, true } }; @@ -109,7 +109,7 @@ bool UserDelegate::InitLocalUserMeta() std::string jsonData = UserMetaData::Marshall(userMetaData); DistributedDB::Value dbValue{ jsonData.begin(), jsonData.end() }; ret = metaDelegate->Put(dbKey, dbValue); - ZLOGI("put user meta data ret %{public}d", ret); + ZLOGI("put user meta data ret=%{public}d", ret); return ret == DistributedDB::DBStatus::OK; } @@ -125,7 +125,7 @@ void UserDelegate::LoadFromMeta(const std::string &deviceId) DistributedDB::Value dbValue; auto ret = metaDelegate->Get(dbKey, dbValue); UserMetaData userMetaData; - ZLOGI("get user meta data ret %{public}d", ret); + ZLOGI("get user meta data ret=%{public}d", ret); if (ret != DistributedDB::DBStatus::OK) { return; } @@ -163,7 +163,7 @@ void UserDelegate::Init() [this](const std::vector &key, const std::vector &value, CHANGE_FLAG flag) { UserMetaData metaData; metaData.Unmarshall({ value.begin(), value.end() }); - ZLOGD("flag:%{public}d, value:%{public}.10s", flag, metaData.deviceId.c_str()); + ZLOGD("flag=%{public}d, value=%{public}.10s", flag, metaData.deviceId.c_str()); if (metaData.deviceId == DeviceKvStoreImpl::GetLocalDeviceId()) { ZLOGD("ignore local device user meta change"); return; @@ -176,7 +176,7 @@ void UserDelegate::Init() ZLOGD("ignored operation"); } }); - ZLOGD("subscribe os account ret:%{public}d", ret); + ZLOGD("subscribe os account ret=%{public}d", ret); } bool UserDelegate::NotifyUserEvent(const UserDelegate::UserEvent &userEvent) @@ -191,7 +191,7 @@ UserDelegate::LocalUserObserver::LocalUserObserver(UserDelegate &userDelegate) : void UserDelegate::LocalUserObserver::OnAccountChanged(const DistributedKv::AccountEventInfo &eventInfo) { - ZLOGI("event info:%{public}s, %{public}d", eventInfo.deviceAccountId.c_str(), eventInfo.status); + ZLOGI("event info=%{public}s, status=%{public}d", eventInfo.deviceAccountId.c_str(), eventInfo.status); userDelegate_.NotifyUserEvent({}); // just notify } diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 1a98804fe..c2e9f268e 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -213,6 +213,7 @@ std::shared_ptr RdbServiceImpl::GetRdbSyncer(const RdbSyncerParam &pa } auto syncer_ = std::make_shared(param, new (std::nothrow) RdbStoreObserverImpl(this, pid)); if (syncer_->Init(pid, uid) != 0) { + ZLOGE("init syncer error"); return false; } syncers[param.storeName_] = syncer_; @@ -236,6 +237,7 @@ int32_t RdbServiceImpl::SetDistributedTables(const RdbSyncerParam ¶m, const ZLOGI("enter"); auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { + ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->SetDistributedTables(tables); @@ -246,6 +248,7 @@ int32_t RdbServiceImpl::DoSync(const RdbSyncerParam ¶m, const SyncOption &op { auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { + ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->DoSync(option, predicates, result); @@ -266,6 +269,7 @@ int32_t RdbServiceImpl::DoAsync(const RdbSyncerParam ¶m, uint32_t seqNum, co ZLOGI("seq num=%{public}u", seqNum); auto syncer = GetRdbSyncer(param); if (syncer == nullptr) { + ZLOGE("syncer is nullptr"); return RDB_ERROR; } return syncer->DoAsync(option, predicates, diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp index 1de876eea..454226871 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_stub.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_stub.cpp @@ -36,6 +36,7 @@ int32_t RdbServiceStub::OnRemoteObtainDistributedTableName(MessageParcel &data, return RDB_OK; } + ZLOGI("successful"); reply.WriteString(ObtainDistributedTableName(device, table)); return RDB_OK; } @@ -60,7 +61,7 @@ int32_t RdbServiceStub::OnRemoteInitNotifier(MessageParcel &data, MessageParcel reply.WriteInt32(error); return RDB_OK; } - ZLOGI("success"); + ZLOGI("successful"); reply.WriteInt32(RDB_OK); return RDB_OK; } @@ -102,10 +103,12 @@ int32_t RdbServiceStub::OnRemoteDoSync(MessageParcel &data, MessageParcel &reply SyncResult result; if (DoSync(param, option, predicates, result) != RDB_OK) { + ZLOGE("DoSync failed"); reply.WriteInt32(RDB_ERROR); return RDB_OK; } if (!DistributedKv::ITypesUtil::Marshalling(result, reply)) { + ZLOGE("Marshalling failed"); reply.WriteInt32(RDB_ERROR); return RDB_OK; } @@ -182,6 +185,7 @@ int RdbServiceStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageP { ZLOGI("code=%{public}d", code); if (!CheckInterfaceToken(data)) { + ZLOGE("check interface token failed"); return RDB_ERROR; } if (code >= 0 && code < RDB_SERVICE_CMD_MAX) { diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.cpp b/services/distributeddataservice/service/rdb/rdb_syncer.cpp index a1813e3b2..2856a5059 100644 --- a/services/distributeddataservice/service/rdb/rdb_syncer.cpp +++ b/services/distributeddataservice/service/rdb/rdb_syncer.cpp @@ -101,7 +101,7 @@ int32_t RdbSyncer::Init(pid_t pid, pid_t uid) ZLOGE("create meta data failed"); return RDB_ERROR; } - ZLOGI("success"); + ZLOGI("successful"); return RDB_OK; } @@ -153,7 +153,7 @@ DistributedDB::RelationalStoreDelegate* RdbSyncer::GetDelegate() ZLOGE("open store failed status=%{public}d", status); return nullptr; } - ZLOGI("open store success"); + ZLOGI("open store successful"); } return delegate_; @@ -174,7 +174,7 @@ int32_t RdbSyncer::SetDistributedTables(const std::vector &tables) return RDB_ERROR; } } - ZLOGE("create distributed table success"); + ZLOGE("create distributed table successful"); return RDB_OK; } -- Gitee