From 08031cf1808de8dff68426bfeb546911d00715cc Mon Sep 17 00:00:00 2001 From: Jing Sima Date: Thu, 22 Aug 2024 09:45:57 +0800 Subject: [PATCH] fix:[TD-31600] Refactor error handling logic in taos_connect_internal. --- source/client/src/clientImpl.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 563d70ab08..eccc63f427 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -176,15 +176,19 @@ int32_t taos_connect_internal(const char* ip, const char* user, const char* pass _return: - code = taosThreadMutexUnlock(&appInfo.mutex); if (TSDB_CODE_SUCCESS != code) { - tscError("failed to unlock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code))); + (void)taosThreadMutexUnlock(&appInfo.mutex); + taosMemoryFreeClear(key); return code; + } else { + code = taosThreadMutexUnlock(&appInfo.mutex); + taosMemoryFreeClear(key); + if (TSDB_CODE_SUCCESS != code) { + tscError("failed to unlock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code))); + return code; + } + return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst, connType, pObj); } - - taosMemoryFreeClear(key); - - return taosConnectImpl(user, &secretEncrypt[0], localDb, NULL, NULL, *pInst, connType, pObj); } //SAppInstInfo* getAppInstInfo(const char* clusterKey) {