From 61734b9c6a5ae61fa05ade40b6c984bfd54c6ec1 Mon Sep 17 00:00:00 2001 From: facetosea <25808407@qq.com> Date: Fri, 6 Jan 2023 10:43:47 +0800 Subject: [PATCH] fix:Deadlock caused by assert modification --- source/os/src/osFile.c | 9 +++++++++ tools/shell/src/shellAuto.c | 3 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 2dfbb28855..71b3125de8 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -368,6 +368,9 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) { #endif ASSERT(pFile->fd >= 0); // Please check if you have closed the file. if (pFile->fd < 0) { +#if FILE_WITH_LOCK + taosThreadRwlockUnlock(&(pFile->rwlock)); +#endif return -1; } int64_t leftbytes = count; @@ -415,6 +418,9 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset) #endif ASSERT(pFile->fd >= 0); // Please check if you have closed the file. if (pFile->fd < 0) { +#if FILE_WITH_LOCK + taosThreadRwlockUnlock(&(pFile->rwlock)); +#endif return -1; } #ifdef WINDOWS @@ -479,6 +485,9 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t #endif ASSERT(pFile->fd >= 0); // Please check if you have closed the file. if (pFile->fd < 0) { +#if FILE_WITH_LOCK + taosThreadRwlockUnlock(&(pFile->rwlock)); +#endif return 0; } #ifdef WINDOWS diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index d49293cc8d..aa1402aef9 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -716,9 +716,6 @@ void putBackAutoPtr(int type, STire* tire) { } else { tires[type]->ref--; ASSERT(tires[type]->ref > 0); - if (tires[type]->ref <= 0) { - return; - } } taosThreadMutexUnlock(&tiresMutex); -- GitLab