From f76a28e5fc8c0484c6a334b86617b5b4903be25a Mon Sep 17 00:00:00 2001 From: y30033032 Date: Sat, 12 Nov 2022 09:27:17 +0800 Subject: [PATCH 1/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- adapter/common/dfx/xcollie_helper.cpp | 41 +++++++++++++++++++ adapter/common/dfx/xcollie_helper_virtual.cpp | 35 ++++++++++++++++ adapter/common/include/xcollie_helper.h | 36 ++++++++++++++++ core/bus_center/bus_center_server.gni | 12 +++++- .../lnn/net_builder/include/lnn_net_builder.h | 2 + .../lnn/net_builder/src/lnn_connection_fsm.c | 3 +- .../lnn/net_builder/src/lnn_net_builder.c | 11 +++++ .../service/src/bus_center_manager.c | 14 +++++++ 8 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 adapter/common/dfx/xcollie_helper.cpp create mode 100644 adapter/common/dfx/xcollie_helper_virtual.cpp create mode 100644 adapter/common/include/xcollie_helper.h diff --git a/adapter/common/dfx/xcollie_helper.cpp b/adapter/common/dfx/xcollie_helper.cpp new file mode 100644 index 0000000000..2436c1f50a --- /dev/null +++ b/adapter/common/dfx/xcollie_helper.cpp @@ -0,0 +1,41 @@ +/* + * 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 "xcollie_helper.h" +#include +#include "softbus_log.h" + +#include "xcollie/watchdog.h" +#include "xcollie/xcollie.h" + +int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) +{ + return OHOS::HiviewDFX::XCollie::GetInstance().SetTimer(name, timeout, func, + args, OHOS::HiviewDFX::XCOLLIE_FLAG_LOG); +} + +void CancelTimer(int id) +{ + return OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id); +} + +void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) +{ + return OHOS::HiviewDFX::Watchdog::GetInstance().RunOneShotTask(name, task, delay); +} + +void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) +{ + return OHOS::HiviewDFX::Watchdog::GetInstance().RunPeriodicalTask(name, task, interval, delay); +} diff --git a/adapter/common/dfx/xcollie_helper_virtual.cpp b/adapter/common/dfx/xcollie_helper_virtual.cpp new file mode 100644 index 0000000000..6232a7e7d9 --- /dev/null +++ b/adapter/common/dfx/xcollie_helper_virtual.cpp @@ -0,0 +1,35 @@ +/* + * 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 +#include "xcollie_helper.h" +int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) +{ + return -1; +} + +void CancelTimer(int id) +{ + return; +} + +void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) +{ + return; +} + +void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) +{ + return; +} diff --git a/adapter/common/include/xcollie_helper.h b/adapter/common/include/xcollie_helper.h new file mode 100644 index 0000000000..83592e5700 --- /dev/null +++ b/adapter/common/include/xcollie_helper.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 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. + */ + +#ifndef XCOLLIE_HELPER_H +#define XCOLLIE_HELPER_H +#include +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif +#endif + +int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args); +void CancelTimer(int id); +void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay); +void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif diff --git a/core/bus_center/bus_center_server.gni b/core/bus_center/bus_center_server.gni index d849061ea8..cd26c73d19 100644 --- a/core/bus_center/bus_center_server.gni +++ b/core/bus_center/bus_center_server.gni @@ -58,10 +58,20 @@ bus_center_server_inc += [ "$dsoftbus_root_path/core/bus_center/ipc/include", "$dsoftbus_root_path/core/bus_center/service/include", "$dsoftbus_root_path/sdk/bus_center/manager/include", + "$softbus_adapter_common/dfx/include", ] bus_center_server_external_deps = [] +if (defined(global_parts_info) && + defined(global_parts_info.hiviewdfx_hicollie_native)) { + bus_center_server_src += [ "$softbus_adapter_common/dfx/xcollie_helper.cpp" ] + bus_center_server_external_deps += [ "hicollie_native:libhicollie" ] +} else { + bus_center_server_src += + [ "$softbus_adapter_common/dfx/xcollie_helper_virtual.cpp" ] +} + if (defined(ohos_lite)) { if (ohos_kernel_type == "liteos_m") { bus_center_server_src += @@ -89,7 +99,7 @@ if (defined(ohos_lite)) { "$dsoftbus_root_path/sdk/frame/$os_type/include", "//utils/system/safwk/native/include", ] - bus_center_server_external_deps = + bus_center_server_external_deps += bus_center_adapter_external_deps + bus_center_ledger_external_deps bus_center_server_external_deps += [ "c_utils:utils" ] } diff --git a/core/bus_center/lnn/net_builder/include/lnn_net_builder.h b/core/bus_center/lnn/net_builder/include/lnn_net_builder.h index 663ccefff5..1079dd8af2 100644 --- a/core/bus_center/lnn/net_builder/include/lnn_net_builder.h +++ b/core/bus_center/lnn/net_builder/include/lnn_net_builder.h @@ -57,6 +57,8 @@ int32_t LnnNotifyAuthHandleLeaveLNN(int64_t authId); int32_t LnnUpdateNodeAddr(const char *addr); AuthVerifyCallback *LnnGetVerifyCallback(void); AuthVerifyCallback *LnnGetMetaVerifyCallback(void); +void SetWatchdogFlag(bool flag); +bool GetWatchdogFlag(void); #ifdef __cplusplus } diff --git a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c index ec0fd0c04c..07485aa474 100644 --- a/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c +++ b/core/bus_center/lnn/net_builder/src/lnn_connection_fsm.c @@ -218,7 +218,7 @@ static void CompleteJoinLNN(LnnConnectionFsm *connFsm, const char *networkId, in LnnConntionInfo *connInfo = &connFsm->connInfo; ReportCategory report; uint8_t relation[CONNECTION_ADDR_MAX] = {0}; - + SetWatchdogFlag(true); LnnFsmRemoveMessage(&connFsm->fsm, FSM_MSG_TYPE_JOIN_LNN_TIMEOUT); if ((connInfo->flag & LNN_CONN_INFO_FLAG_JOIN_AUTO) != 0) { // only report auto network ReportLnnDfx(connFsm, retCode); @@ -832,6 +832,7 @@ int32_t LnnSendJoinRequestToConnFsm(LnnConnectionFsm *connFsm) if (!CheckInterfaceCommonArgs(connFsm, true)) { return SOFTBUS_INVALID_PARAM; } + SetWatchdogFlag(false); return LnnFsmPostMessage(&connFsm->fsm, FSM_MSG_TYPE_JOIN_LNN, NULL); } diff --git a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c index 0c3d8a1d8f..6cb4670504 100755 --- a/core/bus_center/lnn/net_builder/src/lnn_net_builder.c +++ b/core/bus_center/lnn/net_builder/src/lnn_net_builder.c @@ -152,6 +152,17 @@ typedef struct { } MetaAuthInfo; static NetBuilder g_netBuilder; +static bool g_watchdogFlag = true; + +void SetWatchdogFlag(bool flag) +{ + g_watchdogFlag = flag; +} + +bool GetWatchdogFlag(void) +{ + return g_watchdogFlag; +} static void NetBuilderConfigInit(void) { diff --git a/core/bus_center/service/src/bus_center_manager.c b/core/bus_center/service/src/bus_center_manager.c index 7d341e1ff7..1682f80eda 100644 --- a/core/bus_center/service/src/bus_center_manager.c +++ b/core/bus_center/service/src/bus_center_manager.c @@ -30,7 +30,11 @@ #include "softbus_feature_config.h" #include "softbus_log.h" #include "softbus_utils.h" +#include "xcollie_helper.h" +#define WATCHDOG_TASK_NAME "LNN_WATCHDOG_TASK" +#define WATCHDOG_INTERVAL_TIME 10000 +#define WATCHDOG_DELAY_TIME 5000 #define DEFAULT_DELAY_LEN 1000 #define RETRY_MAX 10 @@ -60,6 +64,15 @@ typedef struct { int32_t delayLen; } LnnLocalConfigInit; +static void WatchdogProcess(void) +{ + if (GetWatchdogFlag()) { + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "softbus net_builder thread is online."); + return; + } + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_WARN, "softbus net_builder thread exception."); +} + static LnnLocalConfigInit g_lnnLocalConfigInit = { .initDelayImpl = { [INIT_LOCAL_LEDGER_DELAY_TYPE] = { @@ -164,6 +177,7 @@ int32_t BusCenterServerInit(void) SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init net builder fail!"); return SOFTBUS_ERR; } + RunPeriodicalTask(WATCHDOG_TASK_NAME, WatchdogProcess, WATCHDOG_INTERVAL_TIME, WATCHDOG_DELAY_TIME); if (LnnInitLaneHub() != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init lane hub fail!"); return SOFTBUS_ERR; -- Gitee From 8d902d29823eee84856134a123cb8073f448b702 Mon Sep 17 00:00:00 2001 From: y30033032 Date: Mon, 14 Nov 2022 09:58:49 +0800 Subject: [PATCH 2/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- core/bus_center/service/src/bus_center_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bus_center/service/src/bus_center_manager.c b/core/bus_center/service/src/bus_center_manager.c index 1682f80eda..7e3dd33c33 100644 --- a/core/bus_center/service/src/bus_center_manager.c +++ b/core/bus_center/service/src/bus_center_manager.c @@ -67,7 +67,7 @@ typedef struct { static void WatchdogProcess(void) { if (GetWatchdogFlag()) { - SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "softbus net_builder thread is online."); + SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_INFO, "softbus net_builder thread running normally."); return; } SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_WARN, "softbus net_builder thread exception."); -- Gitee From 0c343c5924fec6b48e991cf7ebe04dd37efb5949 Mon Sep 17 00:00:00 2001 From: y30033032 Date: Mon, 14 Nov 2022 11:15:04 +0800 Subject: [PATCH 3/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- adapter/common/dfx/xcollie_helper_virtual.cpp | 13 ++++++ adapter/common/include/xcollie_helper.h | 45 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/adapter/common/dfx/xcollie_helper_virtual.cpp b/adapter/common/dfx/xcollie_helper_virtual.cpp index 6232a7e7d9..ae249b6a9c 100644 --- a/adapter/common/dfx/xcollie_helper_virtual.cpp +++ b/adapter/common/dfx/xcollie_helper_virtual.cpp @@ -16,20 +16,33 @@ #include "xcollie_helper.h" int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) { + (void)name; + (void)timeout; + (void)func; + (void)args; return -1; } void CancelTimer(int id) { + (void)id; return; } void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) { + (void)name; + (void)task; + (void)delay; return; } void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) { +{ + (void)name; + (void)task; + (void)interval; + (void)delay; return; } diff --git a/adapter/common/include/xcollie_helper.h b/adapter/common/include/xcollie_helper.h index 83592e5700..d38aa358b9 100644 --- a/adapter/common/include/xcollie_helper.h +++ b/adapter/common/include/xcollie_helper.h @@ -22,9 +22,54 @@ extern "C" { #endif #endif +/** +* @brief Called when set timer for service watchdog. +* @param name Indicates the point to the name of the timer. +* @param timeout Indicates the timeout. +* @param func Indicates the point to the callback function. +* @param args Indicates the point to the timer timeout operation.The value can be + XCOLLIE_FLAG_DEFAULT : do all callback function. + XCOLLIE_FLAG_NOOP : do nothing but the caller defined function. + XCOLLIE_FLAG_LOG : generate log file. + XCOLLIE_FLAG_RECOVERY : die when timeout. +* +* @return Return the timer id. +* +* @since 1.0 +* @version 1.0 +*/ int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args); + +/** +* @brief Called when cancel timer of service watchdog. +* @param id Indicates the id of the timer. +* +* @since 1.0 +* @version 1.0 +*/ void CancelTimer(int id); + +/** +* @brief Called when run a onshot task in shared watchdog thread, the submitted task should never be time consuming. +* @param name Indicates the point to the name of the task. +* @param task Indicates the point to a short function name. +* @param delay Indicates delay a few millisecond to run the task. +* +* @since 1.0 +* @version 1.0 +*/ void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay); + +/** +* @brief Called when run a periodical task in shared watchdog thread. +* @param name Indicates the point to the name of the task. +* @param task Indicates the point to a short function name. +* @param interval Indicates the millisecond interval of the periodical task. +* @param delay Indicates delay a few millisecond to first run the task. +* +* @since 1.0 +* @version 1.0 +*/ void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay); #ifdef __cplusplus -- Gitee From fb255303df21cb86489023967e128966098a836b Mon Sep 17 00:00:00 2001 From: y30033032 Date: Mon, 14 Nov 2022 11:28:31 +0800 Subject: [PATCH 4/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- adapter/common/dfx/xcollie_helper_virtual.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/adapter/common/dfx/xcollie_helper_virtual.cpp b/adapter/common/dfx/xcollie_helper_virtual.cpp index ae249b6a9c..7c07ef54de 100644 --- a/adapter/common/dfx/xcollie_helper_virtual.cpp +++ b/adapter/common/dfx/xcollie_helper_virtual.cpp @@ -38,7 +38,6 @@ void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) } void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) -{ { (void)name; (void)task; -- Gitee From ba8ee7055cfb9e19d88768422a1e4e74e5c68688 Mon Sep 17 00:00:00 2001 From: y30033032 Date: Tue, 15 Nov 2022 11:11:43 +0800 Subject: [PATCH 5/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- ...helper.cpp => softbus_adapter_xcollie.cpp} | 27 ++++++++++++++----- ...pp => softbus_adapter_xcollie_virtual.cpp} | 5 +++- ...lie_helper.h => softbus_adapter_xcollie.h} | 22 +++++++-------- core/bus_center/bus_center_server.gni | 4 +-- .../service/src/bus_center_manager.c | 2 +- 5 files changed, 38 insertions(+), 22 deletions(-) rename adapter/common/dfx/{xcollie_helper.cpp => softbus_adapter_xcollie.cpp} (53%) rename adapter/common/dfx/{xcollie_helper_virtual.cpp => softbus_adapter_xcollie_virtual.cpp} (96%) rename adapter/common/include/{xcollie_helper.h => softbus_adapter_xcollie.h} (76%) diff --git a/adapter/common/dfx/xcollie_helper.cpp b/adapter/common/dfx/softbus_adapter_xcollie.cpp similarity index 53% rename from adapter/common/dfx/xcollie_helper.cpp rename to adapter/common/dfx/softbus_adapter_xcollie.cpp index 2436c1f50a..d3c3cf60dc 100644 --- a/adapter/common/dfx/xcollie_helper.cpp +++ b/adapter/common/dfx/softbus_adapter_xcollie.cpp @@ -12,30 +12,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "xcollie_helper.h" + +#include "softbus_adapter_xcollie.h" + #include -#include "softbus_log.h" +#include "softbus_adapter_log.h" +#include "softbus_errcode.h" #include "xcollie/watchdog.h" #include "xcollie/xcollie.h" -int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) +int SoftBusSetWatchdogTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) { + if (name == NULL || func == NULL || args == NULL) { + HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Set Watchdog Timer param is invalid."); + return SOFTBUS_INVALID_PARAM; + } return OHOS::HiviewDFX::XCollie::GetInstance().SetTimer(name, timeout, func, args, OHOS::HiviewDFX::XCOLLIE_FLAG_LOG); } -void CancelTimer(int id) +void SoftBusCancelWatchdogTimer(int id) { return OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id); } -void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) +void SoftBusRunShotWatchdogTask(const char *name, void(*task)(void), uint64_t delay) { + if (name == NULL || task == NULL) { + HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Run Shot Watchdog Task param is invalid."); + return; + } return OHOS::HiviewDFX::Watchdog::GetInstance().RunOneShotTask(name, task, delay); } -void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) +void SoftBusRunPeriodicalWatchdogTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) { + if (name == NULL || task == NULL) { + HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Run Periodical Watchdog Task param is invalid"); + return; + } return OHOS::HiviewDFX::Watchdog::GetInstance().RunPeriodicalTask(name, task, interval, delay); } diff --git a/adapter/common/dfx/xcollie_helper_virtual.cpp b/adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp similarity index 96% rename from adapter/common/dfx/xcollie_helper_virtual.cpp rename to adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp index 7c07ef54de..197e9da282 100644 --- a/adapter/common/dfx/xcollie_helper_virtual.cpp +++ b/adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp @@ -12,8 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include "softbus_adapter_xcollie.h" + #include -#include "xcollie_helper.h" + int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) { (void)name; diff --git a/adapter/common/include/xcollie_helper.h b/adapter/common/include/softbus_adapter_xcollie.h similarity index 76% rename from adapter/common/include/xcollie_helper.h rename to adapter/common/include/softbus_adapter_xcollie.h index d38aa358b9..87cd150e3c 100644 --- a/adapter/common/include/xcollie_helper.h +++ b/adapter/common/include/softbus_adapter_xcollie.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -13,9 +13,11 @@ * limitations under the License. */ -#ifndef XCOLLIE_HELPER_H -#define XCOLLIE_HELPER_H +#ifndef SOFTBUS_ADAPTER_XCOLLIE_H +#define SOFTBUS_ADAPTER_XCOLLIE_H + #include + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -27,18 +29,14 @@ extern "C" { * @param name Indicates the point to the name of the timer. * @param timeout Indicates the timeout. * @param func Indicates the point to the callback function. -* @param args Indicates the point to the timer timeout operation.The value can be - XCOLLIE_FLAG_DEFAULT : do all callback function. - XCOLLIE_FLAG_NOOP : do nothing but the caller defined function. - XCOLLIE_FLAG_LOG : generate log file. - XCOLLIE_FLAG_RECOVERY : die when timeout. +* @param args Indicates the point to the timer timeout operation. * * @return Return the timer id. * * @since 1.0 * @version 1.0 */ -int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args); +int SoftBusSetWatchdogTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args); /** * @brief Called when cancel timer of service watchdog. @@ -47,7 +45,7 @@ int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *a * @since 1.0 * @version 1.0 */ -void CancelTimer(int id); +void SoftBusCancelWatchdogTimer(int id); /** * @brief Called when run a onshot task in shared watchdog thread, the submitted task should never be time consuming. @@ -58,7 +56,7 @@ void CancelTimer(int id); * @since 1.0 * @version 1.0 */ -void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay); +void SoftBusRunShotWatchdogTask(const char *name, void(*task)(void), uint64_t delay); /** * @brief Called when run a periodical task in shared watchdog thread. @@ -70,7 +68,7 @@ void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay); * @since 1.0 * @version 1.0 */ -void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay); +void SoftBusRunPeriodicalWatchdogTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay); #ifdef __cplusplus #if __cplusplus diff --git a/core/bus_center/bus_center_server.gni b/core/bus_center/bus_center_server.gni index cd26c73d19..76f8c5cf79 100644 --- a/core/bus_center/bus_center_server.gni +++ b/core/bus_center/bus_center_server.gni @@ -65,11 +65,11 @@ bus_center_server_external_deps = [] if (defined(global_parts_info) && defined(global_parts_info.hiviewdfx_hicollie_native)) { - bus_center_server_src += [ "$softbus_adapter_common/dfx/xcollie_helper.cpp" ] + bus_center_server_src += [ "$softbus_adapter_common/dfx/softbus_adapter_xcollie.cpp" ] bus_center_server_external_deps += [ "hicollie_native:libhicollie" ] } else { bus_center_server_src += - [ "$softbus_adapter_common/dfx/xcollie_helper_virtual.cpp" ] + [ "$softbus_adapter_common/dfx/softbus_adapter_xcollie_virtual.cpp" ] } if (defined(ohos_lite)) { diff --git a/core/bus_center/service/src/bus_center_manager.c b/core/bus_center/service/src/bus_center_manager.c index 7e3dd33c33..d2a54d24cf 100644 --- a/core/bus_center/service/src/bus_center_manager.c +++ b/core/bus_center/service/src/bus_center_manager.c @@ -177,7 +177,7 @@ int32_t BusCenterServerInit(void) SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init net builder fail!"); return SOFTBUS_ERR; } - RunPeriodicalTask(WATCHDOG_TASK_NAME, WatchdogProcess, WATCHDOG_INTERVAL_TIME, WATCHDOG_DELAY_TIME); + SoftBusRunPeriodicalWatchdogTask(WATCHDOG_TASK_NAME, WatchdogProcess, WATCHDOG_INTERVAL_TIME, WATCHDOG_DELAY_TIME); if (LnnInitLaneHub() != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init lane hub fail!"); return SOFTBUS_ERR; -- Gitee From 9b6c14bdfecf088da5d22c2e11dbd294557fc002 Mon Sep 17 00:00:00 2001 From: y30033032 Date: Tue, 15 Nov 2022 11:34:48 +0800 Subject: [PATCH 6/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- adapter/common/dfx/softbus_adapter_xcollie.cpp | 8 ++++---- adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp | 8 ++++---- adapter/common/include/softbus_adapter_xcollie.h | 8 ++++---- core/bus_center/service/src/bus_center_manager.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/adapter/common/dfx/softbus_adapter_xcollie.cpp b/adapter/common/dfx/softbus_adapter_xcollie.cpp index d3c3cf60dc..3abf2b9412 100644 --- a/adapter/common/dfx/softbus_adapter_xcollie.cpp +++ b/adapter/common/dfx/softbus_adapter_xcollie.cpp @@ -22,7 +22,7 @@ #include "xcollie/watchdog.h" #include "xcollie/xcollie.h" -int SoftBusSetWatchdogTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) +int32_t SoftBusSetWatchdogTimer(const char *name, uint32_t timeout, void(*func)(void*), void *args) { if (name == NULL || func == NULL || args == NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Set Watchdog Timer param is invalid."); @@ -32,12 +32,12 @@ int SoftBusSetWatchdogTimer(const char *name, unsigned int timeout, void(*func)( args, OHOS::HiviewDFX::XCOLLIE_FLAG_LOG); } -void SoftBusCancelWatchdogTimer(int id) +void SoftBusCancelWatchdogTimer(int32_t id) { return OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id); } -void SoftBusRunShotWatchdogTask(const char *name, void(*task)(void), uint64_t delay) +void SoftBusRunOneShotTask(const char *name, void(*task)(void), uint64_t delay) { if (name == NULL || task == NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Run Shot Watchdog Task param is invalid."); @@ -46,7 +46,7 @@ void SoftBusRunShotWatchdogTask(const char *name, void(*task)(void), uint64_t de return OHOS::HiviewDFX::Watchdog::GetInstance().RunOneShotTask(name, task, delay); } -void SoftBusRunPeriodicalWatchdogTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) +void SoftBusRunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) { if (name == NULL || task == NULL) { HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Run Periodical Watchdog Task param is invalid"); diff --git a/adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp b/adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp index 197e9da282..6399da5145 100644 --- a/adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp +++ b/adapter/common/dfx/softbus_adapter_xcollie_virtual.cpp @@ -17,7 +17,7 @@ #include -int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args) +int32_t SoftBusSetWatchdogTimer(const char *name, uint32_t timeout, void(*func)(void*), void *args) { (void)name; (void)timeout; @@ -26,13 +26,13 @@ int SetTimer(const char *name, unsigned int timeout, void(*func)(void*), void *a return -1; } -void CancelTimer(int id) +void SoftBusCancelWatchdogTimer(int32_t id) { (void)id; return; } -void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) +void SoftBusRunOneShotTask(const char *name, void(*task)(void), uint64_t delay) { (void)name; (void)task; @@ -40,7 +40,7 @@ void RunOneShotTask(const char *name, void(*task)(void), uint64_t delay) return; } -void RunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) +void SoftBusRunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) { (void)name; (void)task; diff --git a/adapter/common/include/softbus_adapter_xcollie.h b/adapter/common/include/softbus_adapter_xcollie.h index 87cd150e3c..e01902faaf 100644 --- a/adapter/common/include/softbus_adapter_xcollie.h +++ b/adapter/common/include/softbus_adapter_xcollie.h @@ -36,7 +36,7 @@ extern "C" { * @since 1.0 * @version 1.0 */ -int SoftBusSetWatchdogTimer(const char *name, unsigned int timeout, void(*func)(void*), void *args); +int32_t SoftBusSetWatchdogTimer(const char *name, uint32_t timeout, void(*func)(void*), void *args); /** * @brief Called when cancel timer of service watchdog. @@ -45,7 +45,7 @@ int SoftBusSetWatchdogTimer(const char *name, unsigned int timeout, void(*func)( * @since 1.0 * @version 1.0 */ -void SoftBusCancelWatchdogTimer(int id); +void SoftBusCancelWatchdogTimer(int32_t id); /** * @brief Called when run a onshot task in shared watchdog thread, the submitted task should never be time consuming. @@ -56,7 +56,7 @@ void SoftBusCancelWatchdogTimer(int id); * @since 1.0 * @version 1.0 */ -void SoftBusRunShotWatchdogTask(const char *name, void(*task)(void), uint64_t delay); +void SoftBusRunOneShotTask(const char *name, void(*task)(void), uint64_t delay); /** * @brief Called when run a periodical task in shared watchdog thread. @@ -68,7 +68,7 @@ void SoftBusRunShotWatchdogTask(const char *name, void(*task)(void), uint64_t de * @since 1.0 * @version 1.0 */ -void SoftBusRunPeriodicalWatchdogTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay); +void SoftBusRunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay); #ifdef __cplusplus #if __cplusplus diff --git a/core/bus_center/service/src/bus_center_manager.c b/core/bus_center/service/src/bus_center_manager.c index d2a54d24cf..1a983002e1 100644 --- a/core/bus_center/service/src/bus_center_manager.c +++ b/core/bus_center/service/src/bus_center_manager.c @@ -177,7 +177,7 @@ int32_t BusCenterServerInit(void) SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init net builder fail!"); return SOFTBUS_ERR; } - SoftBusRunPeriodicalWatchdogTask(WATCHDOG_TASK_NAME, WatchdogProcess, WATCHDOG_INTERVAL_TIME, WATCHDOG_DELAY_TIME); + SoftBusRunPeriodicalTask(WATCHDOG_TASK_NAME, WatchdogProcess, WATCHDOG_INTERVAL_TIME, WATCHDOG_DELAY_TIME); if (LnnInitLaneHub() != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "init lane hub fail!"); return SOFTBUS_ERR; -- Gitee From 2148b10e3f0651b7ba32b5d738b311a9bbb0cdcb Mon Sep 17 00:00:00 2001 From: y30033032 Date: Tue, 15 Nov 2022 11:48:49 +0800 Subject: [PATCH 7/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- core/bus_center/service/src/bus_center_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bus_center/service/src/bus_center_manager.c b/core/bus_center/service/src/bus_center_manager.c index 1a983002e1..c03ce1edc7 100644 --- a/core/bus_center/service/src/bus_center_manager.c +++ b/core/bus_center/service/src/bus_center_manager.c @@ -26,11 +26,11 @@ #include "lnn_network_manager.h" #include "lnn_net_builder.h" #include "lnn_net_ledger.h" +#include "softbus_adapter_xcollie.h" #include "softbus_errcode.h" #include "softbus_feature_config.h" #include "softbus_log.h" #include "softbus_utils.h" -#include "xcollie_helper.h" #define WATCHDOG_TASK_NAME "LNN_WATCHDOG_TASK" #define WATCHDOG_INTERVAL_TIME 10000 -- Gitee From 5e2607dc0e2689124d0357b4978d935ceaba0f44 Mon Sep 17 00:00:00 2001 From: y30033032 Date: Tue, 15 Nov 2022 12:47:24 +0800 Subject: [PATCH 8/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- core/bus_center/bus_center_server.gni | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/bus_center/bus_center_server.gni b/core/bus_center/bus_center_server.gni index 76f8c5cf79..dcd2d6e42c 100644 --- a/core/bus_center/bus_center_server.gni +++ b/core/bus_center/bus_center_server.gni @@ -65,7 +65,8 @@ bus_center_server_external_deps = [] if (defined(global_parts_info) && defined(global_parts_info.hiviewdfx_hicollie_native)) { - bus_center_server_src += [ "$softbus_adapter_common/dfx/softbus_adapter_xcollie.cpp" ] + bus_center_server_src += + [ "$softbus_adapter_common/dfx/softbus_adapter_xcollie.cpp" ] bus_center_server_external_deps += [ "hicollie_native:libhicollie" ] } else { bus_center_server_src += -- Gitee From e4c6e9a57da1b007cb6700e4ee8e697808deb044 Mon Sep 17 00:00:00 2001 From: y30033032 Date: Tue, 15 Nov 2022 14:32:19 +0800 Subject: [PATCH 9/9] net_builder service thread add watchdog Signed-off-by: y30033032 --- adapter/common/dfx/softbus_adapter_xcollie.cpp | 6 +++--- adapter/common/include/softbus_adapter_xcollie.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adapter/common/dfx/softbus_adapter_xcollie.cpp b/adapter/common/dfx/softbus_adapter_xcollie.cpp index 3abf2b9412..916721d944 100644 --- a/adapter/common/dfx/softbus_adapter_xcollie.cpp +++ b/adapter/common/dfx/softbus_adapter_xcollie.cpp @@ -34,7 +34,7 @@ int32_t SoftBusSetWatchdogTimer(const char *name, uint32_t timeout, void(*func)( void SoftBusCancelWatchdogTimer(int32_t id) { - return OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id); + OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id); } void SoftBusRunOneShotTask(const char *name, void(*task)(void), uint64_t delay) @@ -43,7 +43,7 @@ void SoftBusRunOneShotTask(const char *name, void(*task)(void), uint64_t delay) HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Run Shot Watchdog Task param is invalid."); return; } - return OHOS::HiviewDFX::Watchdog::GetInstance().RunOneShotTask(name, task, delay); + OHOS::HiviewDFX::Watchdog::GetInstance().RunOneShotTask(name, task, delay); } void SoftBusRunPeriodicalTask(const char *name, void(*task)(void), uint64_t interval, uint64_t delay) @@ -52,5 +52,5 @@ void SoftBusRunPeriodicalTask(const char *name, void(*task)(void), uint64_t inte HILOG_ERROR(SOFTBUS_HILOG_ID, "SoftBus Run Periodical Watchdog Task param is invalid"); return; } - return OHOS::HiviewDFX::Watchdog::GetInstance().RunPeriodicalTask(name, task, interval, delay); + OHOS::HiviewDFX::Watchdog::GetInstance().RunPeriodicalTask(name, task, interval, delay); } diff --git a/adapter/common/include/softbus_adapter_xcollie.h b/adapter/common/include/softbus_adapter_xcollie.h index e01902faaf..0d4857224b 100644 --- a/adapter/common/include/softbus_adapter_xcollie.h +++ b/adapter/common/include/softbus_adapter_xcollie.h @@ -32,7 +32,7 @@ extern "C" { * @param args Indicates the point to the timer timeout operation. * * @return Return the timer id. -* +* * @since 1.0 * @version 1.0 */ -- Gitee