diff --git a/core/bus_center/ipc/include/lnn_bus_center_ipc.h b/core/bus_center/ipc/include/lnn_bus_center_ipc.h index 66caf00640ee4574126ad66028a6cb36c05d38b4..ecf7a4239464c736ae4026f3e86a0679c462aa17 100644 --- a/core/bus_center/ipc/include/lnn_bus_center_ipc.h +++ b/core/bus_center/ipc/include/lnn_bus_center_ipc.h @@ -38,7 +38,7 @@ int32_t LnnIpcSetNodeDataChangeFlag(const char *pkgName, const char *networkId, int32_t LnnIpcGetNodeKeyInfoLen(int32_t key); int32_t LnnIpcStartTimeSync( const char *pkgName, int32_t callingPid, const char *targetNetworkId, int32_t accuracy, int32_t period); -int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId); +int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid); int32_t LnnIpcPublishLNN(const char *pkgName, const PublishInfo *info); int32_t LnnIpcStopPublishLNN(const char *pkgName, int32_t publishId); int32_t LnnIpcRefreshLNN(const char *pkgName, int32_t callingPid, const SubscribeInfo *info); diff --git a/core/bus_center/ipc/mini/lnn_bus_center_ipc.c b/core/bus_center/ipc/mini/lnn_bus_center_ipc.c index f662e8fd7e3f7a79dd36bbd994e08c7daf04ef60..2cf951ebe1e253892a52ca07746478fb4f1dccf4 100644 --- a/core/bus_center/ipc/mini/lnn_bus_center_ipc.c +++ b/core/bus_center/ipc/mini/lnn_bus_center_ipc.c @@ -99,9 +99,9 @@ NO_SANITIZE("cfi") int32_t LnnIpcStartTimeSync(const char *pkgName, int32_t call return LnnStartTimeSync(pkgName, callingPid, targetNetworkId, (TimeSyncAccuracy)accuracy, (TimeSyncPeriod)period); } -NO_SANITIZE("cfi") int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId) +NO_SANITIZE("cfi") int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid) { - return LnnStopTimeSync(pkgName, targetNetworkId); + return LnnStopTimeSync(pkgName, targetNetworkId, callingPid); } NO_SANITIZE("cfi") int32_t LnnIpcPublishLNN(const char *pkgName, const PublishInfo *info) diff --git a/core/bus_center/ipc/small/src/lnn_bus_center_ipc.c b/core/bus_center/ipc/small/src/lnn_bus_center_ipc.c index a8ecf21d01a98fae64c2986ecf8efb808d56aaf9..144a19b8a3c420cdc2f37a64d5f14ede54afe918 100644 --- a/core/bus_center/ipc/small/src/lnn_bus_center_ipc.c +++ b/core/bus_center/ipc/small/src/lnn_bus_center_ipc.c @@ -299,9 +299,9 @@ NO_SANITIZE("cfi") int32_t LnnIpcStartTimeSync(const char *pkgName, int32_t cal return LnnStartTimeSync(pkgName, callingPid, targetNetworkId, (TimeSyncAccuracy)accuracy, (TimeSyncPeriod)period); } -NO_SANITIZE("cfi") int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId) +NO_SANITIZE("cfi") int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid) { - return LnnStopTimeSync(pkgName, targetNetworkId); + return LnnStopTimeSync(pkgName, targetNetworkId, callingPid); } NO_SANITIZE("cfi") int32_t LnnIpcPublishLNN(const char *pkgName, const PublishInfo *info) diff --git a/core/bus_center/ipc/standard/src/lnn_bus_center_ipc.cpp b/core/bus_center/ipc/standard/src/lnn_bus_center_ipc.cpp index 8a70af855594e788f65df3d9e5036ae41c3c6724..aa765f57ffe0db183ab0bb8a37ee24c05f6339ed 100644 --- a/core/bus_center/ipc/standard/src/lnn_bus_center_ipc.cpp +++ b/core/bus_center/ipc/standard/src/lnn_bus_center_ipc.cpp @@ -335,9 +335,9 @@ NO_SANITIZE("cfi") int32_t LnnIpcStartTimeSync(const char *pkgName, int32_t cal return LnnStartTimeSync(pkgName, callingPid, targetNetworkId, (TimeSyncAccuracy)accuracy, (TimeSyncPeriod)period); } -NO_SANITIZE("cfi") int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId) +NO_SANITIZE("cfi") int32_t LnnIpcStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid) { - return LnnStopTimeSync(pkgName, targetNetworkId); + return LnnStopTimeSync(pkgName, targetNetworkId, callingPid); } NO_SANITIZE("cfi") int32_t LnnIpcPublishLNN(const char *pkgName, const PublishInfo *info) diff --git a/core/bus_center/lnn/lane_hub/time_sync/include/lnn_time_sync_manager.h b/core/bus_center/lnn/lane_hub/time_sync/include/lnn_time_sync_manager.h index 6f3cb202e550e8d3923712bca1d2b1707ea930ef..80030a5339fc8f1d2492add84b417e1ce7292e91 100644 --- a/core/bus_center/lnn/lane_hub/time_sync/include/lnn_time_sync_manager.h +++ b/core/bus_center/lnn/lane_hub/time_sync/include/lnn_time_sync_manager.h @@ -25,7 +25,7 @@ extern "C" { int32_t LnnStartTimeSync(const char *pkgName, int32_t callingPid, const char *targetNetworkId, TimeSyncAccuracy accuracy, TimeSyncPeriod period); -int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId); +int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid); int32_t LnnInitTimeSync(void); void LnnDeinitTimeSync(void); diff --git a/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager.c b/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager.c index 9c176247206105f7af87837ec632468c0110ebce..2c81df89dca2ede04585569fbe2f61b20f9e2753 100644 --- a/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager.c +++ b/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager.c @@ -69,6 +69,7 @@ typedef struct { } StartTimeSyncReqMsgPara; typedef struct { + int32_t pid; char pkgName[PKG_NAME_SIZE_MAX]; char targetNetworkId[NETWORK_ID_BUF_LEN]; } StopTimeSyncReqMsgPara; @@ -167,13 +168,13 @@ static int32_t TryUpdateStartTimeSyncReq(TimeSyncReqInfo *info, const StartTimeS return SOFTBUS_OK; } -static void RemoveStartTimeSyncReq(const TimeSyncReqInfo *info, const char *pkgName) +static void RemoveStartTimeSyncReq(const TimeSyncReqInfo *info, const char *pkgName, int32_t callingPid) { StartTimeSyncReq *item = NULL; StartTimeSyncReq *next = NULL; LIST_FOR_EACH_ENTRY_SAFE(item, next, &info->startReqList, StartTimeSyncReq, node) { - if (strcmp(pkgName, item->pkgName) != 0) { + if (strcmp(pkgName, item->pkgName) != 0 || item->pid != callingPid) { continue; } ListDelete(&item->node); @@ -227,7 +228,7 @@ static int32_t ProcessStartTimeSyncRequest(const StartTimeSyncReqMsgPara *para) if (LnnStartTimeSyncImpl(existInfo->targetNetworkId, existInfo->curAccuracy, existInfo->curPeriod, &g_timeSyncImplCb) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "start time sync fail"); - RemoveStartTimeSyncReq(existInfo, para->pkgName); + RemoveStartTimeSyncReq(existInfo, para->pkgName, para->pid); break; } } @@ -293,7 +294,7 @@ static int32_t ProcessStopTimeSyncRequest(const StopTimeSyncReqMsgPara *para) SoftBusFree((void *)para); return SOFTBUS_ERR; } - RemoveStartTimeSyncReq(info, para->pkgName); + RemoveStartTimeSyncReq(info, para->pkgName, para->pid); TryUpdateTimeSyncReq(info); SoftBusFree((void *)para); return SOFTBUS_OK; @@ -335,7 +336,7 @@ static void RemoveAllStartTimeSyncReq(TimeSyncReqInfo *info) StartTimeSyncReq *startTimeSyncNextItem = NULL; LIST_FOR_EACH_ENTRY_SAFE(startTimeSyncItem, startTimeSyncNextItem, &info->startReqList, StartTimeSyncReq, node) { - RemoveStartTimeSyncReq(info, startTimeSyncItem->pkgName); + RemoveStartTimeSyncReq(info, startTimeSyncItem->pkgName, startTimeSyncItem->pid); } (void)LnnStopTimeSyncImpl(info->targetNetworkId); ListDelete(&info->node); @@ -530,7 +531,7 @@ NO_SANITIZE("cfi") int32_t LnnStartTimeSync(const char *pkgName, int32_t calling return SOFTBUS_OK; } -NO_SANITIZE("cfi") int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId) +NO_SANITIZE("cfi") int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid) { StopTimeSyncReqMsgPara *para = NULL; @@ -547,6 +548,7 @@ NO_SANITIZE("cfi") int32_t LnnStopTimeSync(const char *pkgName, const char *targ SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "malloc stop time sync request msg para fail"); return SOFTBUS_MALLOC_ERR; } + para->pid = callingPid; if (strncpy_s(para->pkgName, PKG_NAME_SIZE_MAX, pkgName, strlen(pkgName)) != EOK || strncpy_s(para->targetNetworkId, NETWORK_ID_BUF_LEN, targetNetworkId, strlen(targetNetworkId)) != EOK) { SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "copy time sync request info fail"); diff --git a/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager_virtual.c b/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager_virtual.c index c8d0cc5a797d2a27e7d7e168e3df1257c8aa5f43..f8d1b0389770fdc54b0efeb2180579b8b18be686 100644 --- a/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager_virtual.c +++ b/core/bus_center/lnn/lane_hub/time_sync/src/lnn_time_sync_manager_virtual.c @@ -29,10 +29,11 @@ int32_t LnnStartTimeSync(const char *pkgName, int32_t callingPid, const char *ta return SOFTBUS_NOT_IMPLEMENT; } -int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId) +int32_t LnnStopTimeSync(const char *pkgName, const char *targetNetworkId, int32_t callingPid) { (void)pkgName; (void)targetNetworkId; + (void)callingPid; return SOFTBUS_NOT_IMPLEMENT; } diff --git a/core/frame/small/init/src/bus_center_server_stub.c b/core/frame/small/init/src/bus_center_server_stub.c index b180371ca64051aa03b2a040fe1288fa7f293ea1..44ff15bd4e36753c15f2a11090443c2a4a103ec9 100644 --- a/core/frame/small/init/src/bus_center_server_stub.c +++ b/core/frame/small/init/src/bus_center_server_stub.c @@ -287,7 +287,7 @@ int32_t ServerStopTimeSync(IpcIo *req, IpcIo *reply) SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStopTimeSync no permission."); return SOFTBUS_PERMISSION_DENIED; } - int32_t ret = LnnIpcStopTimeSync(pkgName, targetNetworkId); + int32_t ret = LnnIpcStopTimeSync(pkgName, targetNetworkId, 0); if (ret != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStopTimeSync start time sync failed."); return SOFTBUS_ERR; diff --git a/core/frame/standard/init/src/softbus_server.cpp b/core/frame/standard/init/src/softbus_server.cpp index 5bbb666626beb527632c6318283a5d6e225c8cfb..b66f72938dd01f101ef20f573f478132d56dace7 100644 --- a/core/frame/standard/init/src/softbus_server.cpp +++ b/core/frame/standard/init/src/softbus_server.cpp @@ -238,7 +238,8 @@ int32_t SoftBusServer::StartTimeSync(const char *pkgName, const char *targetNetw int32_t SoftBusServer::StopTimeSync(const char *pkgName, const char *targetNetworkId) { - return LnnIpcStopTimeSync(pkgName, targetNetworkId); + pid_t callingPid = OHOS::IPCSkeleton::GetCallingPid(); + return LnnIpcStopTimeSync(pkgName, targetNetworkId, callingPid); } int32_t SoftBusServer::QosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality) diff --git a/sdk/bus_center/ipc/mini/bus_center_server_proxy.c b/sdk/bus_center/ipc/mini/bus_center_server_proxy.c index 420301e18e211ae6b1e0899d711c7664ca617947..8b62459622cbc0a54fe503f93e42402b9e14a427 100644 --- a/sdk/bus_center/ipc/mini/bus_center_server_proxy.c +++ b/sdk/bus_center/ipc/mini/bus_center_server_proxy.c @@ -87,7 +87,7 @@ int32_t ServerIpcStartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t ServerIpcStopTimeSync(const char *pkgName, const char *targetNetworkId) { - return LnnIpcStopTimeSync(pkgName, targetNetworkId); + return LnnIpcStopTimeSync(pkgName, targetNetworkId, 0); } int32_t ServerIpcPublishLNN(const char *pkgName, const PublishInfo *info)