From 8da395452f229883344815650efedfd99c3dc1b2 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 +++++++++++++++-- 1 file changed, 15 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. */ -- Gitee From f1e39373b7d67f030feb7be5d7c260500edb7723 Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Sun, 29 Sep 2024 07:56:27 +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..5a6e777 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 611f316edb377b2b66deed6a6802a76c957b48cf Mon Sep 17 00:00:00 2001 From: liaoxingxing Date: Sun, 29 Sep 2024 07:57:17 +0000 Subject: [PATCH 3/3] update src/heap-inl.h. Signed-off-by: liaoxingxing --- src/heap-inl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index 5a6e777..3e73b1f 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -179,7 +179,6 @@ HEAP_EXPORT(void heap_remove(struct heap* heap, k -= 1; } - /* Unlink the max node. */ child = *max; *max = NULL; -- Gitee