From 1b37fc333ee678225c88c08e0814c8191c028e30 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Thu, 26 Sep 2024 10:47:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0timer=E5=A0=86=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E7=A8=B3=E5=AE=9A=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 feccbb6..3436fa2 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -481,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 -- Gitee From fc449006c34e3fa81329a65437b95077ad63e47f Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Thu, 26 Sep 2024 11:46:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0timer=E5=A0=86=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E7=A8=B3=E5=AE=9A=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 | 14 ++++---------- src/unix/linux.c | 3 --- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index a919042..e3de2a7 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) { diff --git a/src/unix/linux.c b/src/unix/linux.c index 3436fa2..feccbb6 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -481,9 +481,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