diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 89297cb79e3ace04ca702e5b66f46868a65da05b..0000000000000000000000000000000000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -test/fixtures/lorem_ipsum.txt text eol=lf diff --git a/BUILD.gn b/BUILD.gn index 0ecc6061026460d38bd362f136dda63fcfc615b8..6d3d856f9bed40f8032bc19b9f1463e45557f2c7 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to @@ -194,7 +194,7 @@ if (defined(ohos_lite)) { [ "-Wno-frame-address" ] # for use of __builtin_return_address } - if (use_ohos_dfx && is_ohos) { + if (use_ohos_dfx && is_ohos && !is_emulator) { defines += [ "USE_OHOS_DFX" ] } } else if (is_mingw || is_win) { @@ -300,14 +300,19 @@ if (defined(ohos_lite)) { } if (is_ohos) { sources += [ "src/unix/ohos/trace_ohos.c" ] + if (is_emulator) { + sources += [ "src/unix/ohos/log_ohos.c" ] + } external_deps += [ "hilog:libhilog", "hitrace:hitrace_meter", ] } + if (is_ohos && enable_async_stack) { sources += [ "src/dfx/async_stack/libuv_async_stack.c" ] } + if (is_android) { sources += [ "src/win/log_win.c", diff --git a/include/uv.h b/include/uv.h index 418796d13312a1ffc7eb94cfad5af8613149d359..945c34ecabe9c56ce10d699a41f4cc5d135401ac 100644 --- a/include/uv.h +++ b/include/uv.h @@ -226,6 +226,7 @@ typedef enum { #define UV_EVENT_MAGIC_OFFSET 0x12345ULL #define UV_EVENT_MAGIC_OFFSETBITS 44 + /* Handle types. */ typedef struct uv_loop_s uv_loop_t; typedef struct uv_handle_s uv_handle_t; @@ -1953,6 +1954,7 @@ UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); UV_EXTERN int uv_register_task_to_event(struct uv_loop_s* loop, uv_post_task func, void* handler); UV_EXTERN int uv_unregister_task_to_event(struct uv_loop_s* loop); UV_EXTERN int uv_check_data_valid(struct uv_loop_data* data); + /* String utilities needed internally for dealing with Windows. */ size_t uv_utf16_length_as_wtf8(const uint16_t* utf16, ssize_t utf16_len); diff --git a/src/threadpool.c b/src/threadpool.c index 3035c4e7607e77888ecf94d98fc85b4a873c5922..edd724f6bb44258cb520d199ea863837770ead73 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -35,6 +35,9 @@ #include "ffrt_inner.h" #endif #include +#ifdef ASYNC_STACKTRACE +#include "dfx/async_stack/libuv_async_stack.h" +#endif #define MAX_THREADPOOL_SIZE 1024 #define UV_TRACE_NAME "UV_TRACE" @@ -44,7 +47,6 @@ static uv_once_t once = UV_ONCE_INIT; static uv_cond_t cond; static uv_mutex_t mutex; static unsigned int idle_threads; -static unsigned int slow_io_work_running; static unsigned int nthreads; static uv_thread_t* threads; static uv_thread_t default_threads[4]; @@ -54,10 +56,6 @@ static struct uv__queue run_slow_work_message; static struct uv__queue slow_io_pending_wq; -#ifdef ASYNC_STACKTRACE -#include "dfx/async_stack/libuv_async_stack.h" -#endif - #ifdef UV_STATISTIC #define MAX_DUMP_QUEUE_SIZE 200 static uv_mutex_t dump_queue_mutex; @@ -305,7 +303,7 @@ int is_uv_loop_good_magic(const uv_loop_t* loop) { if (loop->magic == UV_LOOP_MAGIC) { return 1; } - UV_LOGE("uv_loop(%{public}zu:%{public}#x) is invalid", (size_t)loop, loop->magic); + UV_LOGE("loop:(%{public}zu:%{public}#x) invalid", (size_t)loop, loop->magic); return 0; } @@ -313,11 +311,15 @@ int is_uv_loop_good_magic(const uv_loop_t* loop) { void on_uv_loop_close(uv_loop_t* loop) { time_t t1, t2; time(&t1); + uv_start_trace(UV_TRACE_TAG, "Get Write Lock"); uv_rwlock_wrlock(&g_closed_uv_loop_rwlock); + uv_end_trace(UV_TRACE_TAG); loop->magic = ~UV_LOOP_MAGIC; + uv_start_trace(UV_TRACE_TAG, "Release Write Lock"); uv_rwlock_wrunlock(&g_closed_uv_loop_rwlock); + uv_end_trace(UV_TRACE_TAG); time(&t2); - UV_LOGI("uv_loop(%{public}zu) closed in %{public}zds", (size_t)loop, (ssize_t)(t2 - t1)); + UV_LOGI("loop:(%{public}zu) closed in %{public}zds", (size_t)loop, (ssize_t)(t2 - t1)); } @@ -631,7 +633,7 @@ static int uv__work_cancel(uv_loop_t* loop, uv_req_t* req, struct uv__work* w) { uv__loop_internal_fields_t* lfields = uv__get_internal_fields(w->loop); int qos = (ffrt_qos_t)(intptr_t)req->reserved[0]; - if (uv_check_data_valid((struct uv_loop_data*)(loop->data)) == 0) { + if (uv_check_data_valid((struct uv_loop_data*)(w->loop->data)) == 0) { int status = (w->work == uv__cancelled) ? UV_ECANCELED : 0; struct uv_loop_data* addr = (struct uv_loop_data*)((uint64_t)w->loop->data - (UV_EVENT_MAGIC_OFFSET << UV_EVENT_MAGIC_OFFSETBITS)); @@ -663,7 +665,7 @@ void uv__work_done(uv_async_t* handle) { return; } rdunlock_closed_uv_loop_rwlock(); - + uv_mutex_lock(&loop->wq_mutex); #ifndef USE_FFRT uv__queue_move(&loop->wq, &wq); @@ -830,6 +832,9 @@ void uv__work_submit(uv_loop_t* loop, ffrt_task_attr_set_qos(&attr, ffrt_qos_background); break; default: +#ifdef USE_OHOS_DFX + UV_LOGI("Unknown work kind"); +#endif return; } diff --git a/src/timer.c b/src/timer.c index 0734f43a0bc5e05c5e2cc428377fc18bd6801101..35548b421ca56f39ece914b2aafc17e540b47746 100644 --- a/src/timer.c +++ b/src/timer.c @@ -97,7 +97,6 @@ int uv_timer_start(uv_timer_t* handle, (struct heap_node*) &handle->heap_node, timer_less_than); uv__handle_start(handle); - #ifdef __linux__ if (uv_check_data_valid((struct uv_loop_data*)handle->loop->data) == 0) { uv_async_send(&handle->loop->wq_async); diff --git a/src/unix/async.c b/src/unix/async.c index e0d9bb7635ed8a02bbbb3aca586ed2498cc8536f..7f744c4c53847dcf5905aba440c5ced138395620 100644 --- a/src/unix/async.c +++ b/src/unix/async.c @@ -64,6 +64,13 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { int uv_async_send(uv_async_t* handle) { _Atomic int* pending; +#ifdef USE_OHOS_DFX + if (handle == NULL) { + UV_LOGF("handle is NULL"); + return -1; + } +#endif + pending = (_Atomic int*) &handle->pending; @@ -151,7 +158,7 @@ static void uv__async_send(uv_async_t* handle) { uv_loop_t* loop = handle->loop; if (loop == NULL) { - UV_LOGE("fatal error! loop is NULL"); + UV_LOGF("loop is NULL"); return; } @@ -214,8 +221,7 @@ static int uv__async_start(uv_loop_t* loop) { uv__io_init(&loop->async_io_watcher, uv__async_io, pipefd[0]); uv__io_start(loop, &loop->async_io_watcher, POLLIN); loop->async_wfd = pipefd[1]; - UV_LOGI("open: loop addr is %{public}zu, loop->async_wfd is %{public}d," - "loop->async_io_watcher.fd is %{public}d", (size_t)loop, loop->async_wfd, pipefd[0]); + UV_LOGI("open:%{public}zu, pipefd[0]:%{public}d", (size_t)loop, pipefd[0]); return 0; } @@ -236,7 +242,7 @@ void uv__async_stop(uv_loop_t* loop) { if (loop->async_wfd != -1) { if (loop->async_wfd != loop->async_io_watcher.fd) { - UV_LOGI("close: loop addr is %{public}zu, loop->async_wfd is %{public}d", (size_t)loop, loop->async_wfd); + UV_LOGI("close:%{public}zu, async_wfd:%{public}d", (size_t)loop, loop->async_wfd); uv__close(loop->async_wfd); } loop->async_wfd = -1; @@ -248,8 +254,7 @@ void uv__async_stop(uv_loop_t* loop) { #else uv__close(loop->async_io_watcher.fd); #endif - UV_LOGI("close: loop addr is %{public}zu, loop->async_io_watcher.fd is %{public}d", - (size_t)loop, loop->async_io_watcher.fd); + UV_LOGI("close:%{public}zu, async_io_wfd:%{public}d", (size_t)loop, loop->async_io_watcher.fd); loop->async_io_watcher.fd = -1; } diff --git a/src/unix/core.c b/src/unix/core.c index e38ac559eb0a5a4681ba145a1fea19ced5ede785..ba7c8cef32d667947ad6dface7a70faf147ea355 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -1938,7 +1938,7 @@ int uv_register_task_to_event(struct uv_loop_s* loop, uv_post_task func, void* h if (data == NULL) return -1; if ((uint64_t)data >> UV_EVENT_MAGIC_OFFSETBITS != 0x0) { - UV_LOGE("malloc address error!"); + UV_LOGE("malloc address error"); free(data); return -1; } @@ -1954,13 +1954,13 @@ int uv_register_task_to_event(struct uv_loop_s* loop, uv_post_task func, void* h #endif } + int uv_unregister_task_to_event(struct uv_loop_s* loop) { #if defined(__aarch64__) if (loop == NULL || loop->data == NULL || ((uint64_t)loop->data >> UV_EVENT_MAGIC_OFFSETBITS) != (uint64_t)(UV_EVENT_MAGIC_OFFSET)) return -1; - loop->data = (struct uv_loop_data*)((uint64_t)loop->data - (UV_EVENT_MAGIC_OFFSET << UV_EVENT_MAGIC_OFFSETBITS)); free(loop->data); @@ -1971,6 +1971,7 @@ int uv_unregister_task_to_event(struct uv_loop_s* loop) #endif } + int uv_check_data_valid(struct uv_loop_data* data) { #if defined(__aarch64__) if (data == NULL || ((uint64_t)data >> UV_EVENT_MAGIC_OFFSETBITS) != (uint64_t)(UV_EVENT_MAGIC_OFFSET)) { @@ -1979,11 +1980,12 @@ int uv_check_data_valid(struct uv_loop_data* data) { struct uv_loop_data* addr = (struct uv_loop_data*)((uint64_t)data - (UV_EVENT_MAGIC_OFFSET << UV_EVENT_MAGIC_OFFSETBITS)); if (addr->post_task_func == NULL) { - UV_LOGE("post_task_func is NULL"); + UV_LOGE("post_task_func NULL"); return -1; } return 0; #else return -1; #endif -} \ No newline at end of file +} + diff --git a/src/unix/linux.c b/src/unix/linux.c index 67a17c5aa69de522e320b25538467e3ab9281e92..5042ea658ba0b3e315c060f16dc6cfabadb722d0 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -671,7 +671,7 @@ int uv__platform_loop_init(uv_loop_t* loop) { uv__iou_init(loop->backend_fd, &lfields->iou, 64, UV__IORING_SETUP_SQPOLL); uv__iou_init(loop->backend_fd, &lfields->ctl, 256, 0); - UV_LOGI("loop init: loop add is %{public}zu, backend_fd is %{public}d", (size_t)loop, loop->backend_fd); + UV_LOGI("init:%{public}zu, backend_fd:%{public}d", (size_t)loop, loop->backend_fd); return 0; } @@ -1510,8 +1510,13 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { continue; } +#ifndef USE_OHOS_DFX assert(fd >= 0); assert((unsigned) fd < loop->nwatchers); +#else + if (fd < 0 || (unsigned) fd >= loop->nwatchers) + continue; +#endif w = loop->watchers[fd]; diff --git a/src/unix/log_unix.c b/src/unix/log_unix.c index 2105a6821ba9447f7d5b97a1ccb4aa587a429521..056c87cf0f8b2c9fbdbbe5f519fd2dcd629638b4 100644 --- a/src/unix/log_unix.c +++ b/src/unix/log_unix.c @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 "uv_log.h" diff --git a/src/unix/loop.c b/src/unix/loop.c index 6c579de078fa9c16dc4e063aca4f02277c571785..2cb896aa40319469ca619159f1e4371a26675868 100644 --- a/src/unix/loop.c +++ b/src/unix/loop.c @@ -33,7 +33,7 @@ int uv_loop_init(uv_loop_t* loop) { void* saved_data; int err; - UV_LOGI("loop init: loop addr is %{public}zu", (size_t)loop); + UV_LOGI("init:%{public}zu", (size_t)loop); saved_data = loop->data; memset(loop, 0, sizeof(*loop)); loop->data = saved_data; @@ -190,19 +190,13 @@ void uv__loop_close(uv_loop_t* loop) { #else uv__close(loop->backend_fd); #endif - UV_LOGI("close: loop addr is %{public}zu, loop->backend_fd is %{public}d", (size_t)loop, loop->backend_fd); + UV_LOGI("close:%{public}zu, backend_fd:%{public}d", (size_t)loop, loop->backend_fd); loop->backend_fd = -1; } uv_mutex_lock(&loop->wq_mutex); #ifndef USE_FFRT assert(uv__queue_empty(&loop->wq) && "thread pool work queue not empty!"); -#else - uv__loop_internal_fields_t* lfields_qos = uv__get_internal_fields(loop); - assert(uv__queue_empty(&(lfields_qos->wq_sub[uv_qos_background])) && "thread pool work queue qos_background not empty!"); - assert(uv__queue_empty(&(lfields_qos->wq_sub[uv_qos_utility])) && "thread pool work queue qos_utility not empty!"); - assert(uv__queue_empty(&(lfields_qos->wq_sub[uv_qos_default])) && "thread pool work queue qos_default not empty!"); - assert(uv__queue_empty(&(lfields_qos->wq_sub[uv_qos_user_initiated])) && "thread pool work queue qos_user_initiated not empty!"); #endif assert(!uv__has_active_reqs(loop)); uv_mutex_unlock(&loop->wq_mutex); diff --git a/src/unix/ohos/log_ohos.c b/src/unix/ohos/log_ohos.c new file mode 100644 index 0000000000000000000000000000000000000000..643562bcdfcfed72ef878e009196ef4dcc62349a --- /dev/null +++ b/src/unix/ohos/log_ohos.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 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 "uv_log.h" +#include "hilog/log.h" + +#include + +extern int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *fmt, va_list ap); + +LogLevel convert_uv_log_level(enum uv__log_level level) { + switch (level) + { + case UV_DEBUG: + return LOG_DEBUG; + case UV_INFO: + return LOG_INFO; + case UV_WARN: + return LOG_WARN; + case UV_ERROR: + return LOG_ERROR; + case UV_FATAL: + return LOG_FATAL; + default: + return LOG_LEVEL_MIN; + } +} + +int uv__log_impl(enum uv__log_level level, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = HiLogPrintArgs(LOG_CORE, convert_uv_log_level(level), 0xD003301, "LIBUV", fmt, args); + va_end(args); + return ret; +} \ No newline at end of file diff --git a/src/unix/ohos/trace_ohos.c b/src/unix/ohos/trace_ohos.c index ba855baf0fafb0dc3de5e763c8734e88e8cf0bf7..51512dec7b35275502bfbf86d404a191682d5e60 100644 --- a/src/unix/ohos/trace_ohos.c +++ b/src/unix/ohos/trace_ohos.c @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 "uv_trace.h" diff --git a/src/unix/signal.c b/src/unix/signal.c index bc4206e6d864c8eed412d3c50e47438968465bfd..90c8ce2f77ae6ea9fe2f4894d7f353980c072109 100644 --- a/src/unix/signal.c +++ b/src/unix/signal.c @@ -20,6 +20,7 @@ #include "uv.h" #include "internal.h" +#include "uv_log.h" #include #include @@ -103,8 +104,14 @@ static void uv__signal_global_reinit(void) { if (uv__make_pipe(uv__signal_lock_pipefd, 0)) abort(); - if (uv__signal_unlock()) + if (uv__signal_unlock()) { +#ifdef USE_OHOS_DFX + UV_LOGF("errno:%{public}d, sig_lock_pfd[1]:%{public}d", errno, uv__signal_lock_pipefd[1]); + return; +#else abort(); +#endif + } } @@ -148,14 +155,26 @@ static void uv__signal_block_and_lock(sigset_t* saved_sigmask) { if (pthread_sigmask(SIG_SETMASK, &new_mask, saved_sigmask)) abort(); - if (uv__signal_lock()) + if (uv__signal_lock()) { +#ifdef USE_OHOS_DFX + UV_LOGF("errno:%{public}d, sig_lock_pfd[0]:%{public}d", errno, uv__signal_lock_pipefd[0]); + return; +#else abort(); +#endif + } } static void uv__signal_unlock_and_unblock(sigset_t* saved_sigmask) { - if (uv__signal_unlock()) + if (uv__signal_unlock()) { +#ifdef USE_OHOS_DFX + UV_LOGF("errno:%{public}d, sig_lock_pfd[1]:%{public}d", errno, uv__signal_lock_pipefd[1]); + return; +#else abort(); +#endif + } if (pthread_sigmask(SIG_SETMASK, saved_sigmask, NULL)) abort(); @@ -461,8 +480,14 @@ static void uv__signal_event(uv_loop_t* loop, } /* Other errors really should never happen. */ - if (r == -1) + if (r == -1) { +#ifdef USE_OHOS_DFX + UV_LOGF("errno:%{public}d, sig_pfd[0]:%{public}d", errno, loop->signal_pipefd[0]); + return; +#else abort(); +#endif + } bytes += r; diff --git a/src/unix/trace_unix.c b/src/unix/trace_unix.c index f84e38aa03b46787a7ebdd26de98d93bd89ce4d1..020f1a4b58089a20c7bf90c68b972681a0f55d04 100644 --- a/src/unix/trace_unix.c +++ b/src/unix/trace_unix.c @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 "uv_trace.h" diff --git a/src/uv-common.c b/src/uv-common.c index e2309de7c1b00e729703f54d6e981dc2747a2aae..c766d09589e01b132b0e98081af8e6bf2f6b55da 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -21,6 +21,7 @@ #include "uv.h" #include "uv-common.h" +#include "uv_log.h" #include #include @@ -856,13 +857,20 @@ int uv_loop_close(uv_loop_t* loop) { void* saved_data; #endif - if (uv__has_active_reqs(loop)) + if (uv__has_active_reqs(loop)) { +#ifdef USE_OHOS_DFX + UV_LOGI("loop:%{public}zu, active reqs:%{public}u", (size_t)loop, loop->active_reqs.count); +#endif return UV_EBUSY; - + } uv__queue_foreach(q, &loop->handle_queue) { h = uv__queue_data(q, uv_handle_t, handle_queue); - if (!(h->flags & UV_HANDLE_INTERNAL)) + if (!(h->flags & UV_HANDLE_INTERNAL)) { +#ifdef USE_OHOS_DFX + UV_LOGI("loop:%{public}zu, active handle:%{public}zu", (size_t)loop, (size_t)h); +#endif return UV_EBUSY; + } } on_uv_loop_close(loop); diff --git a/src/uv_log.h b/src/uv_log.h index a75ebb83836b170656a97380ef40d0bb71d16eb8..5a34476e101b4be841fd568e98d5d8c896337ecf 100644 --- a/src/uv_log.h +++ b/src/uv_log.h @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 UV_LOG_H diff --git a/src/uv_trace.h b/src/uv_trace.h index 619f741935457e3c95ebfb9024bdd1a42d96f977..6a4449cd23d0d783d0ff6d09c5d8bf19e2df4abd 100644 --- a/src/uv_trace.h +++ b/src/uv_trace.h @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 UV_TRACE_H diff --git a/src/win/log_win.c b/src/win/log_win.c index 2105a6821ba9447f7d5b97a1ccb4aa587a429521..056c87cf0f8b2c9fbdbbe5f519fd2dcd629638b4 100644 --- a/src/win/log_win.c +++ b/src/win/log_win.c @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 "uv_log.h" diff --git a/src/win/trace_win.c b/src/win/trace_win.c index f84e38aa03b46787a7ebdd26de98d93bd89ce4d1..020f1a4b58089a20c7bf90c68b972681a0f55d04 100644 --- a/src/win/trace_win.c +++ b/src/win/trace_win.c @@ -1,21 +1,16 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: +/* + * Copyright (c) 2024 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. + * 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 "uv_trace.h"