From 169decae331e2d978f41178f9d4ed37b8263ffeb Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Wed, 9 Oct 2024 21:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8uv=5F=5Fffrt=5Fwork=E4=B8=AD=E7=A7=BB?= =?UTF-8?q?=E9=99=A4lfields=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoxingxing --- BUILD.gn | 3 --- src/threadpool.c | 18 +++++------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index c8d5995..9d17a31 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -350,9 +350,6 @@ if (defined(ohos_lite)) { } ohos_shared_library("uv") { deps = [ ":libuv_source" ] - if (is_linux || is_ohos) { - ldflags = [ "-Wl,--exclude-libs=ALL" ] - } external_deps = [ "hilog:libhilog" ] public_configs = [ ":libuv_config" ] subsystem_name = "thirdparty" diff --git a/src/threadpool.c b/src/threadpool.c index 923a637..07e0440 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -678,10 +678,6 @@ void uv__work_done(uv_async_t* handle) { uv__queue_append(&lfields->wq_sub[i], &wq); } } - - if (loop->active_reqs > 1000) { - UV_LOGW("there are %{public}u tasks in loop thread", loop->active_reqs); - } #endif uv_mutex_unlock(&loop->wq_mutex); @@ -766,24 +762,19 @@ void uv__ffrt_work(ffrt_executor_task_t* data, ffrt_qos_t qos) #ifdef UV_STATISTIC uv__post_statistic_work(w, WORK_EXECUTING); #endif -#ifdef ASYNC_STACKTRACE uv_work_t* req = container_of(w, uv_work_t, work_req); +#ifdef ASYNC_STACKTRACE LibuvSetStackId((uint64_t)req->reserved[3]); #endif w->work(w); #ifdef UV_STATISTIC uv__post_statistic_work(w, WORK_END); #endif - uv__loop_internal_fields_t* lfields = uv__get_internal_fields(loop); rdlock_closed_uv_loop_rwlock(); - if (loop->magic != UV_LOOP_MAGIC - || !lfields - || qos >= ARRAY_SIZE(lfields->wq_sub) - || !lfields->wq_sub[qos].next - || !lfields->wq_sub[qos].prev) { + if (loop->magic != UV_LOOP_MAGIC) { rdunlock_closed_uv_loop_rwlock(); - UV_LOGE("uv_loop(%{public}zu:%{public}#x), task is invalid", - (size_t)loop, loop->magic); + UV_LOGE("uv_loop(%{public}zu:%{public}#x) in task(%p:%p) is invalid", + (size_t)loop, loop->magic, req->work_cb, req->after_work_cb); return; } @@ -796,6 +787,7 @@ void uv__ffrt_work(ffrt_executor_task_t* data, ffrt_qos_t qos) (UV_EVENT_MAGIC_OFFSET << UV_EVENT_MAGIC_OFFSETBITS)); addr->post_task_func(addr->event_handler, uv__task_done_wrapper, (void*)w, status, qos); } else { + uv__loop_internal_fields_t* lfields = uv__get_internal_fields(loop); uv__queue_insert_tail(&(lfields->wq_sub[qos]), &w->wq); uv_async_send(&loop->wq_async); }