From 3e2fa73c971e6651349bcd18d7ffcabbc51bedbe Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Fri, 9 May 2025 16:37:09 +0800 Subject: [PATCH] modify uv__copy_taskname Signed-off-by: liaoxingxing --- src/threadpool.c | 2 +- src/uv-common.c | 37 +++++++++++++++---------------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/threadpool.c b/src/threadpool.c index 990dc1b..19acc7d 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -493,10 +493,10 @@ void uv__work_done(uv_async_t* handle) { #endif #ifdef USE_OHOS_DFX - uv__print_active_reqs(loop, "complete"); if (uv_check_data_valid((struct uv_loop_data*)(loop->data)) == 0) { return; } + uv__print_active_reqs(loop, "complete"); #endif uv_mutex_lock(&loop->wq_mutex); diff --git a/src/uv-common.c b/src/uv-common.c index 2a840b1..61378f5 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -1066,6 +1066,21 @@ uint64_t uv__get_addr_tag(void* addr) { } +#ifdef USE_FFRT +int uv__copy_taskname(uv_req_t* req, const char* task_name) { + char* str = (char*)calloc(TASK_NAME_LENGTH, sizeof(char)); + if (str == NULL) { + UV_LOGE("calloc task name failed, task name:%{public}s", task_name); + return UV_EINVAL; + } + + snprintf(str, TASK_NAME_LENGTH, "%s", task_name); + req->reserved[1] = (void*)str; + return 0; +} +#endif + + #if defined(USE_OHOS_DFX) && defined(__aarch64__) static uv_once_t thread_check_guard = UV_ONCE_INIT; void init_param_once() { @@ -1130,26 +1145,4 @@ void uv__multi_thread_check_unify(const uv_loop_t* loop, const char* funcName) { abort(); } } -#endif - -#ifdef USE_FFRT -int uv__copy_taskname(uv_req_t* req, const char* task_name) { - char* str = (char*)malloc(TASK_NAME_LENGTH); - if (str == NULL) { - UV_LOGE("malloc task name failed, task name:%{public}s", task_name); - return UV_EINVAL; - } - - char* pos_first = strchr(task_name, SPLIT_CHAR_FIRST); - char* pos_end = strchr(task_name, SPLIT_CHAR_SECOND); - pos_first = (pos_first == NULL ? (char*)task_name : pos_first + 1); - snprintf(str, TASK_NAME_LENGTH, "%s", pos_first); - int end = TASK_NAME_LENGTH - 1; - if (pos_end > pos_first && (pos_end - pos_first) < TASK_NAME_LENGTH - 1) { - end = pos_end - pos_first; - } - str[end] = '\0'; - req->reserved[1] = (void*)str; - return 0; -} #endif \ No newline at end of file -- Gitee