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 268d1e5d58eb2879e348dd709950926fab938f36..065945c80fdfe637f2762633effe1334299db376 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 @@ -184,17 +184,13 @@ if (defined(ohos_lite)) { defines += [ "ASYNC_STACKTRACE" ] } - if (enable_print_errno_abort && is_ohos) { - defines += [ "PRINT_ERRNO_ABORT" ] - } - if (enable_uv_statisic && is_ohos) { defines += [ "UV_STATISTIC" ] cflags += [ "-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) { @@ -239,6 +235,7 @@ if (defined(ohos_lite)) { } ohos_source_set("libuv_source") { + branch_protector_ret = "pac_ret" configs = [ ":libuv_config" ] cflags = [ "-fvisibility=hidden" ] sources = common_source @@ -246,13 +243,13 @@ if (defined(ohos_lite)) { if (is_mac || (defined(is_ios) && is_ios)) { sources += nonwin_srcs + [ "src/unix/bsd-ifaddrs.c", - "src/unix/kqueue.c", - "src/unix/random-getentropy.c", "src/unix/darwin-proctitle.c", "src/unix/darwin.c", "src/unix/fsevents.c", - "src/unix/os390-proctitle.c", + "src/unix/kqueue.c", "src/unix/log_unix.c", + "src/unix/os390-proctitle.c", + "src/unix/random-getentropy.c", "src/unix/trace_unix.c", ] } else if (is_mingw || is_win) { @@ -289,24 +286,29 @@ if (defined(ohos_lite)) { sources += nonwin_srcs + [ "src/unix/linux.c", "src/unix/procfs-exepath.c", + "src/unix/proctitle.c", "src/unix/random-getentropy.c", "src/unix/random-getrandom.c", "src/unix/random-sysctl-linux.c", - "src/unix/proctitle.c", ] if (libuv_use_ffrt) { external_deps += [ "ffrt:libffrt" ] } 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", @@ -316,20 +318,20 @@ if (defined(ohos_lite)) { } else if (is_linux) { sources += nonwin_srcs + [ "src/unix/linux.c", + "src/unix/log_unix.c", "src/unix/procfs-exepath.c", + "src/unix/proctitle.c", "src/unix/random-getrandom.c", "src/unix/random-sysctl-linux.c", - "src/unix/proctitle.c", - "src/unix/log_unix.c", "src/unix/trace_unix.c", ] } else { sources += nonwin_srcs + [ "src/unix/linux.c", "src/unix/procfs-exepath.c", + "src/unix/proctitle.c", "src/unix/random-getrandom.c", "src/unix/random-sysctl-linux.c", - "src/unix/proctitle.c", ] } subsystem_name = "thirdparty" @@ -344,13 +346,13 @@ if (defined(ohos_lite)) { } ohos_shared_library("uv") { deps = [ ":libuv_source" ] - external_deps = [ "hilog:libhilog" ] public_configs = [ ":libuv_config" ] subsystem_name = "thirdparty" innerapi_tags = [ "platformsdk" ] part_name = "libuv" if (is_ohos) { output_extension = "so" + external_deps = [ "hilog:libhilog" ] } install_images = [ "system", diff --git a/include/uv.h b/include/uv.h index 418796d13312a1ffc7eb94cfad5af8613149d359..0d39684b8e71dca3ea92a16321fa7e480a295c0a 100644 --- a/include/uv.h +++ b/include/uv.h @@ -188,7 +188,7 @@ struct uv__queue { XX(GETNAMEINFO, getnameinfo) \ XX(RANDOM, random) \ -#ifdef PRINT_ERRNO_ABORT +#ifdef USE_OHOS_DFX #include "info/fatal_message.h" #define UV_ERRNO_ABORT(...) \ do { \ @@ -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; @@ -1186,6 +1187,7 @@ typedef enum { uv_qos_utility = 1, uv_qos_default = 2, uv_qos_user_initiated = 3, + uv_qos_user_interactive = 4, } uv_qos_t; UV_EXTERN int uv_queue_work_with_qos(uv_loop_t* loop, @@ -1953,6 +1955,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/libuv.gni b/libuv.gni index 9fed6ba309c09c6e405906dbfe8ca5023e50f175..75f8d752b5b1be67134fbfae7ec6dd3b923b569a 100644 --- a/libuv.gni +++ b/libuv.gni @@ -15,6 +15,5 @@ declare_args() { libuv_use_ffrt = false enable_async_stack = true enable_uv_statisic = false - enable_print_errno_abort = true use_ohos_dfx = true } diff --git a/src/heap-inl.h b/src/heap-inl.h index 1e2ed60e09417c481f07a51c59d9866baa7ebe81..e3de2a7056d6509157d7730de8daa54854a1c48b 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -17,6 +17,7 @@ #define UV_SRC_HEAP_H_ #include /* NULL */ +#include "uv_log.h" #if defined(__GNUC__) # define HEAP_EXPORT(declaration) __attribute__((unused)) static declaration @@ -178,12 +179,18 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 1; } - heap->nelts -= 1; - /* Unlink the max node. */ child = *max; *max = NULL; +#ifdef USE_OHOS_DFX + if (child == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif + heap->nelts -= 1; + if (child == node) { /* We're removing either the max or the last node in the tree. */ if (child == heap->min) { diff --git a/src/threadpool.c b/src/threadpool.c index 4a1ac04ad306b495898ab5dadf11b2691114e979..ee86f7b1340f8bf93ff472f74b92dc445bab9f82 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -35,16 +35,24 @@ #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" +#ifdef USE_OHOS_DFX +#define MIN_REQS_THRESHOLD 100 +#define MAX_REQS_THRESHOLD 300 +#define CURSOR 5 +#endif + static uv_rwlock_t g_closed_uv_loop_rwlock; 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 +62,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 +309,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 +317,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)); } @@ -404,10 +412,6 @@ static void worker(void* arg) { w = uv__queue_data(q, struct uv__work, wq); #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); - LibuvSetStackId((uint64_t)req->reserved[3]); #endif w->work(w); #ifdef UV_STATISTIC @@ -580,9 +584,23 @@ void uv__work_submit(uv_loop_t* loop, #endif +static void uv__print_active_reqs(uv_loop_t* loop, const char* flag) { +#ifdef USE_OHOS_DFX + unsigned int count = loop->active_reqs.count; + if (count == MIN_REQS_THRESHOLD || count == MIN_REQS_THRESHOLD + CURSOR || + count == MAX_REQS_THRESHOLD || count == MAX_REQS_THRESHOLD + CURSOR) { + UV_LOGW("loop:%{public}zu, flag:%{public}s, active reqs:%{public}u", (size_t)loop, flag, count); + } +#else + return; +#endif +} + + #ifdef USE_FFRT static void uv__task_done_wrapper(void* work, int status) { struct uv__work* w = (struct uv__work*)work; + uv__print_active_reqs(w->loop, "complete"); w->done(w, status); } #endif @@ -631,7 +649,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)); @@ -657,11 +675,17 @@ void uv__work_done(uv_async_t* handle) { int nevents; loop = container_of(handle, uv_loop_t, wq_async); +#ifdef USE_OHOS_DFX + if (uv_check_data_valid((struct uv_loop_data*)(loop->data)) != 0) + uv__print_active_reqs(loop, "complete"); +#endif rdlock_closed_uv_loop_rwlock(); if (!is_uv_loop_good_magic(loop)) { rdunlock_closed_uv_loop_rwlock(); return; } + rdunlock_closed_uv_loop_rwlock(); + uv_mutex_lock(&loop->wq_mutex); #ifndef USE_FFRT uv__queue_move(&loop->wq, &wq); @@ -669,7 +693,7 @@ void uv__work_done(uv_async_t* handle) { uv__loop_internal_fields_t* lfields = uv__get_internal_fields(loop); int i; uv__queue_init(&wq); - for (i = 3; i >= 0; i--) { + for (i = 4; i >= 0; i--) { if (!uv__queue_empty(&lfields->wq_sub[i])) { uv__queue_append(&lfields->wq_sub[i], &wq); } @@ -694,10 +718,6 @@ void uv__work_done(uv_async_t* handle) { } dump_work->info = w->info; dump_work->work = uv__update_work_info; -#endif -#ifdef ASYNC_STACKTRACE - uv_work_t* req = container_of(w, uv_work_t, work_req); - LibuvSetStackId((uint64_t)req->reserved[3]); #endif w->done(w, err); nevents++; @@ -709,7 +729,6 @@ void uv__work_done(uv_async_t* handle) { #endif } uv_end_trace(UV_TRACE_TAG); - rdunlock_closed_uv_loop_rwlock(); /* This check accomplishes 2 things: * 1. Even if the queue was empty, the call to uv__work_done() should count @@ -728,7 +747,9 @@ void uv__work_done(uv_async_t* handle) { static void uv__queue_work(struct uv__work* w) { uv_work_t* req = container_of(w, uv_work_t, work_req); - +#ifdef ASYNC_STACKTRACE + LibuvSetStackId((uint64_t)req->reserved[3]); +#endif req->work_cb(req); } @@ -742,6 +763,9 @@ static void uv__queue_done(struct uv__work* w, int err) { } req = container_of(w, uv_work_t, work_req); +#ifdef ASYNC_STACKTRACE + LibuvSetStackId((uint64_t)req->reserved[3]); +#endif uv__req_unregister(req->loop, req); if (req->after_work_cb == NULL) @@ -758,25 +782,16 @@ void uv__ffrt_work(ffrt_executor_task_t* data, ffrt_qos_t qos) uv_loop_t* loop = w->loop; #ifdef UV_STATISTIC uv__post_statistic_work(w, WORK_EXECUTING); -#endif - 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) in task(%p:%p) is invalid", - (size_t)loop, loop->magic, req->work_cb, req->after_work_cb); + UV_LOGE("uv_loop(%{public}zu:%{public}#x), task is invalid", + (size_t)loop, loop->magic); return; } @@ -789,6 +804,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); } @@ -829,6 +845,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; } @@ -872,6 +891,7 @@ int uv_queue_work(uv_loop_t* loop, if (work_cb == NULL) return UV_EINVAL; + uv__print_active_reqs(loop, "execute"); uv__req_init(loop, req, UV_WORK); req->loop = loop; req->work_cb = work_cb; @@ -920,10 +940,12 @@ int uv_queue_work_with_qos(uv_loop_t* loop, STATIC_ASSERT(uv_qos_utility == ffrt_qos_utility); STATIC_ASSERT(uv_qos_default == ffrt_qos_default); STATIC_ASSERT(uv_qos_user_initiated == ffrt_qos_user_initiated); - if (qos < ffrt_qos_background || qos > ffrt_qos_user_initiated) { + STATIC_ASSERT(uv_qos_user_interactive == ffrt_qos_deadline_request); + if (qos < ffrt_qos_background || qos > ffrt_qos_deadline_request) { return UV_EINVAL; } + uv__print_active_reqs(loop, "execute"); uv__req_init(loop, req, UV_WORK); req->loop = loop; req->work_cb = work_cb; 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..65a029ca8832bb5ad636c121f28607a8df56f394 100644 --- a/src/unix/async.c +++ b/src/unix/async.c @@ -39,6 +39,11 @@ #include #endif +#ifdef USE_FFRT +#include "ffrt.h" +#include "c/executor_task.h" +#endif + static void uv__async_send(uv_async_t* handle); static int uv__async_start(uv_loop_t* loop); @@ -64,6 +69,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; @@ -114,7 +126,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { if (errno == EINTR) continue; -#ifdef PRINT_ERRNO_ABORT +#ifdef USE_OHOS_DFX UV_ERRNO_ABORT("errno is %d, loop addr is %zu, fd is %d (%s:%s:%d)", errno, (size_t)loop, w->fd, __FILE__, __func__, __LINE__); #else @@ -151,7 +163,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; } @@ -179,7 +191,7 @@ static void uv__async_send(uv_async_t* handle) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) return; -#ifdef PRINT_ERRNO_ABORT +#ifdef USE_OHOS_DFX UV_ERRNO_ABORT("errno is %d, loop addr is %zu, fd is %d (%s:%s:%d)", errno, (size_t)loop, fd, __FILE__, __func__, __LINE__); #else @@ -214,8 +226,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,20 +247,25 @@ 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; } uv__io_stop(loop, &loop->async_io_watcher, POLLIN); +#ifdef USE_FFRT + if (ffrt_get_cur_task() != NULL) { + uv__epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, loop->async_io_watcher.fd, NULL); + } +#endif + #if defined(__linux__) && defined(USE_OHOS_DFX) fdsan_close_with_tag(loop->async_io_watcher.fd, uv__get_addr_tag((void *)&loop->async_io_watcher)); #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/internal.h b/src/unix/internal.h index 80e596a1b831b9de7ce6ff6a404f1815d7488586..4a92125ae6d5cb513a661c91c3914554ac76c4b5 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -35,6 +35,11 @@ #include #include #include + +#ifdef USE_FFRT +#include +#endif + #define UV_LOOP_MAGIC 0x100B100BU #define uv__msan_unpoison(p, n) \ do { \ @@ -262,6 +267,10 @@ int uv__fd_exists(uv_loop_t* loop, int fd); void uv__async_stop(uv_loop_t* loop); int uv__async_fork(uv_loop_t* loop); +#ifdef USE_FFRT +/* epoll */ +int uv__epoll_ctl(int epoll_fd, int op, int fd, struct epoll_event* event); +#endif /* loop */ void uv__run_idle(uv_loop_t* loop); @@ -472,4 +481,11 @@ uv__fs_copy_file_range(int fd_in, #define UV__CPU_AFFINITY_SUPPORTED 0 #endif +UV_UNUSED(static unsigned int self_increase(unsigned int* ptr)) { + return __sync_fetch_and_add(ptr, 1); +} + +UV_UNUSED(static unsigned int self_decrease(unsigned int* ptr)) { + return __sync_fetch_and_sub(ptr, 1); +} #endif /* UV_UNIX_INTERNAL_H_ */ diff --git a/src/unix/linux.c b/src/unix/linux.c index 67a17c5aa69de522e320b25538467e3ab9281e92..dcf07d4274eaffba81a8bc89ee865e7fa2bd1822 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -55,6 +55,7 @@ #include #include #include + #ifdef USE_FFRT #include "ffrt.h" #include "c/executor_task.h" @@ -73,7 +74,7 @@ int uv__epoll_ctl(int epoll_fd, int op, int fd, struct epoll_event* event) { #ifdef USE_FFRT if (ffrt_get_cur_task() != NULL) { ffrt_qos_t qos = ffrt_this_task_get_qos(); - return ffrt_epoll_ctl(qos, op, fd, event->events, NULL, NULL); + return ffrt_epoll_ctl(qos, op, fd, event == NULL ? 0 : event->events, NULL, NULL); } #endif return epoll_ctl(epoll_fd, op, fd ,event); @@ -480,6 +481,9 @@ int uv__io_uring_register(int fd, unsigned opcode, void* arg, unsigned nargs) { static int uv__use_io_uring(void) { +#if defined(USE_OHOS_DFX) + return 0; +#endif #if defined(__ANDROID_API__) return 0; /* Possibly available but blocked by seccomp. */ #elif defined(__arm__) && __SIZEOF_POINTER__ == 4 @@ -671,7 +675,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; } @@ -1244,6 +1248,7 @@ static void uv__epoll_ctl_prep(int epollfd, struct epoll_event* pe; uint32_t mask; uint32_t slot; + int ret = 0; if (ctl->ringfd == -1) { if (!uv__epoll_ctl(epollfd, op, fd, e)) @@ -1252,17 +1257,35 @@ static void uv__epoll_ctl_prep(int epollfd, if (op == EPOLL_CTL_DEL) return; /* Ignore errors, may be racing with another thread. */ - if (op != EPOLL_CTL_ADD) + if (op != EPOLL_CTL_ADD) { +#ifdef USE_OHOS_DFX + UV_ERRNO_ABORT("errno is %d, fd is %d, backend_fd is %d(%s:%s:%d)", + errno, fd, epollfd, __FILE__, __func__, __LINE__); +#else abort(); +#endif + } - if (errno != EEXIST) + if (errno != EEXIST) { +#ifdef USE_OHOS_DFX + UV_ERRNO_ABORT("errno is %d, fd is %d, backend_fd is %d(%s:%s:%d)", + errno, fd, epollfd, __FILE__, __func__, __LINE__); +#else abort(); +#endif + } /* File descriptor that's been watched before, update event mask. */ - if (!uv__epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, e)) + ret = uv__epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, e); + if (!ret) return; +#ifdef USE_OHOS_DFX + UV_ERRNO_ABORT("errno is %d, uv__epoll_ctl ret is %d, fd is %d, backend_fd is %d(%s:%s:%d)", + errno, ret, fd, epollfd, __FILE__, __func__, __LINE__); +#else abort(); +#endif } else { mask = ctl->sqmask; slot = (*ctl->sqtail)++ & mask; @@ -1510,8 +1533,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]; @@ -1521,6 +1549,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * Ignore all errors because we may be racing with another thread * when the file descriptor is closed. */ + UV_LOGF("fd %{public}d don't belong to loop %{public}zu", fd, (size_t)loop); uv__epoll_ctl_prep(epollfd, ctl, &prep, EPOLL_CTL_DEL, fd, pe); continue; } 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..9832cd107b9fb6ac1fbf42a9abaf6bea04144731 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; @@ -42,7 +42,6 @@ int uv_loop_init(uv_loop_t* loop) { if (lfields == NULL) return UV_ENOMEM; loop->internal_fields = lfields; - err = uv_mutex_init(&lfields->loop_metrics.lock); if (err) goto fail_metrics_mutex_init; @@ -58,6 +57,7 @@ int uv_loop_init(uv_loop_t* loop) { uv__queue_init(&(lfields_qos->wq_sub[uv_qos_utility])); uv__queue_init(&(lfields_qos->wq_sub[uv_qos_default])); uv__queue_init(&(lfields_qos->wq_sub[uv_qos_user_initiated])); + uv__queue_init(&(lfields_qos->wq_sub[uv_qos_user_interactive])); #endif uv__queue_init(&loop->idle_handles); @@ -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..f644ffc8a5ab1edd8e3b2a839eb2fff733ee110d --- /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; +} 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..9b644c68b192b0a9dc8fb5ba35d1fe9daa268659 100644 --- a/src/unix/signal.c +++ b/src/unix/signal.c @@ -20,7 +20,12 @@ #include "uv.h" #include "internal.h" - +#include "uv_log.h" +#ifdef USE_FFRT +#include "ffrt_inner.h" +#include +#include +#endif #include #include #include @@ -103,8 +108,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 +159,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(); @@ -322,6 +345,11 @@ void uv__signal_loop_cleanup(uv_loop_t* loop) { } if (loop->signal_pipefd[0] != -1) { +#ifdef USE_FFRT + if (ffrt_get_cur_task() != NULL) { + uv__epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, loop->signal_pipefd[0], NULL); + } +#endif uv__close(loop->signal_pipefd[0]); loop->signal_pipefd[0] = -1; } @@ -430,6 +458,36 @@ static int uv__signal_start(uv_signal_t* handle, } +#ifdef USE_FFRT +static void uv__get_process_name(char* processName, int bufferLength) { + int fd = open("/proc/self/cmdline", O_RDONLY); + if (fd != -1) { + ssize_t ret = syscall(SYS_read, fd, processName, bufferLength - 1); + if (ret != -1) { + processName[ret] = '\0'; + } + syscall(SYS_close, fd); + } +} + +static int uv__get_signal_flag() { + static int trigger = -1; + + if (trigger == -1) { + char processName[1024] = {0}; + uv__get_process_name(processName, sizeof(processName)); + char* c = strstr(processName, "com.atomicservice."); + if (c == NULL || c > processName) { + trigger = 0; + } else { + trigger = 1; + } + } + return trigger; +} +#endif + + static void uv__signal_event(uv_loop_t* loop, uv__io_t* w, unsigned int events) { @@ -441,7 +499,9 @@ static void uv__signal_event(uv_loop_t* loop, bytes = 0; end = 0; - +#ifdef USE_FFRT + unsigned int trigger = uv__get_signal_flag(); +#endif do { r = read(loop->signal_pipefd[0], buf + bytes, sizeof(buf) - bytes); @@ -461,8 +521,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; @@ -475,7 +541,13 @@ static void uv__signal_event(uv_loop_t* loop, if (msg->signum == handle->signum) { assert(!(handle->flags & UV_HANDLE_CLOSING)); +#ifdef USE_FFRT + if (trigger != 1) { + handle->signal_cb(handle, handle->signum); + } +#else handle->signal_cb(handle, handle->signum); +#endif } handle->dispatched_signals++; 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 35581c9c7e3590d61f83d699725c0901906f9559..13419f494630c3a337f4b8a72a99a50eefd1954d 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 @@ -537,6 +538,7 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { struct uv__queue* q; uv_handle_t* h; + UV_LOGI("clean up handles in loop(%{public}zu)", (size_t)loop); uv__queue_move(&loop->handle_queue, &queue); while (!uv__queue_empty(&queue)) { q = uv__queue_head(&queue); @@ -856,13 +858,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); @@ -889,6 +898,10 @@ void uv_loop_delete(uv_loop_t* loop) { err = uv_loop_close(loop); (void) err; /* Squelch compiler warnings. */ assert(err == 0); +#ifdef USE_OHOS_DFX + if (err != 0) + on_uv_loop_close(loop); +#endif if (loop != default_loop) uv__free(loop); } diff --git a/src/uv-common.h b/src/uv-common.h index bcff87a01d7bfaa86b8d07857dda832e9befe1eb..7ca246f5762a136852a7f38bba9385491bbea457 100644 --- a/src/uv-common.h +++ b/src/uv-common.h @@ -236,6 +236,21 @@ void uv__threadpool_cleanup(void); #define uv__has_active_reqs(loop) \ ((loop)->active_reqs.count > 0) +#if defined(USE_FFRT) && defined(USE_OHOS_DFX) +#define uv__req_register(loop, req) \ + do { \ + self_increase((unsigned int*)(&((loop)->active_reqs.count))); \ + } \ + while (0) + +#define uv__req_unregister(loop, req) \ + do { \ + if(!uv__has_active_reqs(loop)) \ + break; \ + self_decrease((unsigned int*)(&((loop)->active_reqs.count))); \ + } \ + while (0) +#else #define uv__req_register(loop, req) \ do { \ (loop)->active_reqs.count++; \ @@ -248,6 +263,7 @@ void uv__threadpool_cleanup(void); (loop)->active_reqs.count--; \ } \ while (0) +#endif #define uv__has_active_handles(loop) \ ((loop)->active_handles > 0) @@ -432,7 +448,7 @@ struct uv__loop_internal_fields_s { void* inv; /* used by uv__platform_invalidate_fd() */ #endif /* __linux__ */ #ifdef USE_FFRT - struct uv__queue wq_sub[4]; + struct uv__queue wq_sub[5]; #endif }; 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"