From 0c588d965eeb0592b2d05a8034c22adee4c6ce59 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sun, 28 May 2023 16:30:43 +0800 Subject: [PATCH] bugfixed: fast_mblock_batch_alloc correct return value --- HISTORY | 3 ++- src/fast_mblock.c | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/HISTORY b/HISTORY index 30a45f4..1e6dc03 100644 --- a/HISTORY +++ b/HISTORY @@ -1,11 +1,12 @@ -Version 1.67 2023-05-23 +Version 1.67 2023-05-28 * lc_pair in struct fc_queue change to lcp * sorted queue use double link chain for quick push * add function uniq_skiplist_clear * fast_mblock_malloc_trunk_notify_func prototype changed * fast_mblock_init_ex2 add parameter prealloc_trunk_count * sorted_queue.[hc] support pop_compare_func + * bugfixed: fast_mblock_batch_alloc correct return value Version 1.66 2023-02-12 * struct fast_task_info add field: notify_next for nio notify queue diff --git a/src/fast_mblock.c b/src/fast_mblock.c index b6d6b66..11499d4 100644 --- a/src/fast_mblock.c +++ b/src/fast_mblock.c @@ -878,16 +878,17 @@ int fast_mblock_batch_alloc(struct fast_mblock_man *mblock, { struct fast_mblock_node *pNode; int i; + int lr; int result; - if (mblock->need_lock && (result=pthread_mutex_lock( + if (mblock->need_lock && (lr=pthread_mutex_lock( &mblock->lcp.lock)) != 0) { logError("file: "__FILE__", line: %d, " "call pthread_mutex_lock fail, " "errno: %d, error info: %s", - __LINE__, result, STRERROR(result)); - return result; + __LINE__, lr, STRERROR(lr)); + return lr; } if ((chain->head=alloc_node(mblock)) != NULL) { @@ -914,13 +915,13 @@ int fast_mblock_batch_alloc(struct fast_mblock_man *mblock, result = ENOMEM; } - if (mblock->need_lock && (result=pthread_mutex_unlock( + if (mblock->need_lock && (lr=pthread_mutex_unlock( &mblock->lcp.lock)) != 0) { - logError("file: "__FILE__", line: %d, " \ - "call pthread_mutex_unlock fail, " \ - "errno: %d, error info: %s", \ - __LINE__, result, STRERROR(result)); + logError("file: "__FILE__", line: %d, " + "call pthread_mutex_unlock fail, " + "errno: %d, error info: %s", + __LINE__, lr, STRERROR(lr)); } return result;