diff --git a/src/threadpool.c b/src/threadpool.c index 553800dd38266b95ab2307caf77c85e0c30398c9..b5d328a0908bce2c91427cc14153d0d3b643548c 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -387,6 +387,7 @@ void uv__work_submit_to_eventloop(uv_req_t* req, struct uv__work* w, int qos) { int status = (w->work == uv__cancelled) ? UV_ECANCELED : 0; struct uv_loop_data* addr = (struct uv_loop_data*)((uint64_t)loop->data - (UV_EVENT_MAGIC_OFFSET << UV_EVENT_MAGIC_OFFSETBITS)); + uv_mutex_unlock(&loop->wq_mutex); if (req->type == UV_WORK) { addr->post_task_func((char*)req->reserved[1], uv__task_done_wrapper, (void*)w, status, qos); } else { @@ -395,9 +396,9 @@ void uv__work_submit_to_eventloop(uv_req_t* req, struct uv__work* w, int qos) { } else { uv__loop_internal_fields_t* lfields = uv__get_internal_fields(loop); uv__queue_insert_tail(&(lfields->wq_sub[qos]), &w->wq); + uv_mutex_unlock(&loop->wq_mutex); uv_async_send(&loop->wq_async); } - uv_mutex_unlock(&loop->wq_mutex); rdunlock_closed_uv_loop_rwlock(); } #endif @@ -492,8 +493,10 @@ void uv__work_done(uv_async_t* handle) { #endif #ifdef USE_OHOS_DFX - if (uv_check_data_valid((struct uv_loop_data*)(loop->data)) != 0) - uv__print_active_reqs(loop, "complete"); + uv__print_active_reqs(loop, "complete"); + if (uv_check_data_valid((struct uv_loop_data*)(loop->data)) == 0) { + return; + } #endif uv_mutex_lock(&loop->wq_mutex); diff --git a/src/uv-common.c b/src/uv-common.c index 4ea45dbd7cdba146f21d6868cfae99e7be7e99aa..2a840b11edead6f0b5a332b8d91a6493ef9c19c3 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -1069,7 +1069,7 @@ uint64_t uv__get_addr_tag(void* addr) { #if defined(USE_OHOS_DFX) && defined(__aarch64__) static uv_once_t thread_check_guard = UV_ONCE_INIT; void init_param_once() { - unsigned int param_value = GetIntParameter("persist.libuv.properties", -1); + int param_value = GetIntParameter("persist.libuv.properties", -1); if (param_value == 1) { g_multi_thread_check = 1; } @@ -1094,7 +1094,6 @@ void uv__init_thread_id(uv_loop_t* loop) { if (uv__is_multi_thread_open()) { uv__loop_internal_fields_t* lfields_tid = uv__get_internal_fields(loop); lfields_tid->thread_id = 0; - lfields_tid->thread_id |= MULTI_THREAD_CHECK_LOOP_INIT; } } @@ -1102,7 +1101,7 @@ void uv__init_thread_id(uv_loop_t* loop) { void uv__set_thread_id(uv_loop_t* loop) { if (uv__is_multi_thread_open()) { uv__loop_internal_fields_t* lfields_tid = uv__get_internal_fields(loop); - lfields_tid->thread_id |= (unsigned int)gettid(); + lfields_tid->thread_id = (unsigned int)gettid(); } } @@ -1110,8 +1109,7 @@ void uv__set_thread_id(uv_loop_t* loop) { static unsigned int uv__get_thread_id(const uv_loop_t* loop) { if (uv__is_multi_thread_open()) { uv__loop_internal_fields_t* lfields_tid = uv__get_internal_fields(loop); - unsigned int thread_id = lfields_tid->thread_id & ~MULTI_THREAD_CHECK_LOOP_INIT; - return thread_id; + return lfields_tid->thread_id; } else { return 0; } diff --git a/src/uv-common.h b/src/uv-common.h index 0bc5238ee1ec5987cee7a7c2092907c903bac65c..ff6acc0a0a7dd31e637f20448077c9069faa13f2 100644 --- a/src/uv-common.h +++ b/src/uv-common.h @@ -41,9 +41,6 @@ # include #endif -#if defined(USE_OHOS_DFX) && defined(__aarch64__) -#define MULTI_THREAD_CHECK_LOOP_INIT 0x80000000 -#endif #if EDOM > 0 # define UV__ERR(x) (-(x)) #else