fix: rectify codes' difference

Signed-off-by: jialinbo <jialinbo@huawei.com>
This commit is contained in:
jialinbo 2024-09-24 08:09:45 +00:00
parent 63ee7d1a5f
commit d873d44386
8 changed files with 19 additions and 10 deletions

View File

@ -152,7 +152,6 @@
"test": [
"//foundation/communication/ipc/ipc/test:moduletest",
"//foundation/communication/ipc/ipc/native/test:unittest",
"//foundation/communication/ipc/interfaces/innerkits/rust/tests:unittest",
"//foundation/communication/ipc/ipc/native/test/fuzztest:fuzztest",
"//foundation/communication/ipc/services/dbinder/test/unittest:unittest",
"//foundation/communication/ipc/services/dbinder/test/fuzztest:fuzztest"

View File

@ -48,7 +48,6 @@ ohos_shared_library("ipc_common") {
"c_utils:utils",
"hilog:libhilog",
"hisysevent:libhisysevent",
"json:nlohmann_json_static",
]
defines = [ "FFRT_IPC_ENABLE" ]

View File

@ -22,7 +22,8 @@
namespace OHOS {
class CommAuthInfo {
public:
CommAuthInfo(IRemoteObject *stub, int pid, int uid, uint32_t tokenId, const std::string &deviceId);
CommAuthInfo(IRemoteObject *stub, int pid, int uid, uint32_t tokenId,
const std::string &deviceId, int32_t socketId = 0);
virtual ~CommAuthInfo();
IRemoteObject *GetStubObject() const;
int GetRemotePid() const;

View File

@ -16,8 +16,10 @@
#include "comm_auth_info.h"
namespace OHOS {
CommAuthInfo::CommAuthInfo(IRemoteObject *stub, int pid, int uid, uint32_t tokenId, const std::string &deviceId)
: stub_(stub), remotePid_(pid), remoteUid_(uid), tokenId_(tokenId), deviceId_(deviceId), socketId_(0)
CommAuthInfo::CommAuthInfo(IRemoteObject *stub, int pid, int uid, uint32_t tokenId,
const std::string &deviceId, int32_t socketId)
: stub_(stub), remotePid_(pid), remoteUid_(uid),
tokenId_(tokenId), deviceId_(deviceId), socketId_(socketId)
{}
CommAuthInfo::~CommAuthInfo()

View File

@ -150,7 +150,6 @@ bool ProcessSkeleton::AttachObject(IRemoteObject *object, const std::u16string &
{
CHECK_INSTANCE_EXIT_WITH_RETVAL(exitFlag_, false);
std::unique_lock<std::shared_mutex> lockGuard(objMutex_, std::defer_lock);
ZLOGD(LOG_LABEL, "The value of lockflag is:%{public}d", lockFlag);
if (lockFlag) {
lockGuard.lock();
}

View File

@ -131,8 +131,17 @@ uint32_t IpcCApiParcelUnitTest::CalcSpendTime(TimePoint& start, TimePoint& end)
void IpcCApiParcelUnitTest::PerformanceStatistic(uint32_t writeAvg, uint32_t readAvg,
uint32_t writeCppAvg, uint32_t readCppAvg)
{
static constexpr uint32_t percent = 100;
static constexpr uint32_t percentRange = 105;
static constexpr uint32_t errorValue = 5000; // ns
std::cout << "OHIPCParcel writeAvg:" << writeAvg << "ns, readAvg:" << readAvg << "ns" << std::endl;
std::cout << "MessageParcel writeAvg:" << writeCppAvg << "ns, readAvg:" << readCppAvg << "ns" << std::endl;
if (writeCppAvg >= errorValue) {
ASSERT_LE(writeAvg * percent, writeCppAvg * percentRange);
}
if (readCppAvg >= errorValue) {
ASSERT_LE(readAvg * percent, readCppAvg * percentRange);
}
}
void IpcCApiParcelUnitTest::ReadWriteString(const char *str, uint32_t &writeDuration, uint32_t &readDuration)

View File

@ -15,7 +15,6 @@ import("//build/test.gni")
SUBSYSTEM_DIR = "//foundation/communication/ipc"
IPC_TEST_ROOT = "//foundation/communication/ipc/ipc/test"
IPC_CORE_ROOT = "//foundation/communication/ipc/ipc/native/c"
config("ipc_test_config") {
include_dirs = [
@ -24,7 +23,6 @@ config("ipc_test_config") {
"$SUBSYSTEM_DIR/utils/include",
"$SUBSYSTEM_DIR/ipc/native/src/mock/include",
"$SUBSYSTEM_DIR/interfaces/innerkits/c_api/include",
"$IPC_CORE_ROOT/src/c_api/include",
]
}

View File

@ -530,7 +530,7 @@ std::shared_ptr<DHandleEntryTxRx> DBinderService::PopLoadSaItem(const std::strin
std::lock_guard<std::shared_mutex> lockGuard(loadSaMutex_);
auto it = std::find_if(loadSaReply_.begin(), loadSaReply_.end(), checkSaItem);
if (it == loadSaReply_.end()) {
DBINDER_LOGI(LOG_LABEL, "findSaItem failed saId:%{public}d, deviceId:%{public}s",
DBINDER_LOGI(LOG_LABEL, "no msg for saId:%{public}d, deviceId:%{public}s",
systemAbilityId, DBinderService::ConvertToSecureDeviceID(srcNetworkId).c_str());
return nullptr;
}
@ -670,6 +670,7 @@ bool DBinderService::OnRemoteInvokerMessage(std::shared_ptr<struct DHandleEntryT
SendReplyMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_NOT_AVAILABLE, replyMessage);
return false;
}
return true;
}
@ -763,7 +764,8 @@ bool DBinderService::SetReplyMessage(std::shared_ptr<struct DHandleEntryTxRx> re
return true;
}
uint32_t DBinderService::OnRemoteInvokerDataBusMessage(IPCObjectProxy *proxy, std::shared_ptr<struct DHandleEntryTxRx> replyMessage,
uint32_t DBinderService::OnRemoteInvokerDataBusMessage(IPCObjectProxy *proxy,
std::shared_ptr<struct DHandleEntryTxRx> replyMessage,
std::string &remoteDeviceId, int pid, int uid, uint32_t tokenId)
{
if (CheckDeviceIdIllegal(remoteDeviceId)) {