From 1d2ffa99269b2bb57e23fa71777b6e56a9fafa87 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Thu, 26 Sep 2024 10:47:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?cherry=20pick=201b37fc3=20from=20https://gi?= =?UTF-8?q?tee.com/liaoxingbin/third=5Fparty=5Flibuv/pulls/184=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0timer=E5=A0=86=E6=93=8D=E4=BD=9C=E7=A8=B3=E5=AE=9A?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoxingxing --- src/heap-inl.h | 17 +++++++++++++++-- src/unix/linux.c | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index 1e2ed60..a919042 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 @@ -137,6 +138,12 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, /* Insert the new node. */ newnode->parent = *parent; +#ifdef USE_OHOS_DFX + if (child == NULL || newnode == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif *child = newnode; heap->nelts += 1; @@ -178,11 +185,17 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 1; } - heap->nelts -= 1; - +#ifdef USE_OHOS_DFX + if (child == NULL) { + UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); + return; + } +#endif + /* Unlink the max node. */ child = *max; *max = NULL; + heap->nelts -= 1; if (child == node) { /* We're removing either the max or the last node in the tree. */ diff --git a/src/unix/linux.c b/src/unix/linux.c index 67a17c5..5a8b8ba 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -480,6 +480,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 -- Gitee From a187042595b280777e6f4029cd214f2d1b46cdfe Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Sun, 29 Sep 2024 08:00:32 +0000 Subject: [PATCH 2/3] update src/heap-inl.h. Signed-off-by: liaoxingxing --- src/heap-inl.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index a919042..03a3bde 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -138,12 +138,6 @@ HEAP_EXPORT(void heap_insert(struct heap* heap, /* Insert the new node. */ newnode->parent = *parent; -#ifdef USE_OHOS_DFX - if (child == NULL || newnode == NULL) { - UV_LOGF("Child is NULL, this may be due to multi-threaded calls."); - return; - } -#endif *child = newnode; heap->nelts += 1; @@ -185,16 +179,16 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 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 - - /* Unlink the max node. */ - child = *max; - *max = NULL; heap->nelts -= 1; if (child == node) { -- Gitee From 818be3f71ca53cc305fc7837367ebff4053de995 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Sun, 29 Sep 2024 08:01:35 +0000 Subject: [PATCH 3/3] update src/unix/linux.c. Signed-off-by: liaoxingxing --- src/unix/linux.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/unix/linux.c b/src/unix/linux.c index 5a8b8ba..67a17c5 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -480,9 +480,6 @@ 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 -- Gitee