提交 5f5fdc71 编写于 作者: dengyihao's avatar dengyihao

[TD-11316]<fix> fix mem leak when taos_connect failed

上级 96d4f0a7
......@@ -29,6 +29,7 @@
#include "ttimer.h"
#include "tscProfile.h"
static char clusterDefaultId[] = "clusterDefaultId";
static bool validImpl(const char* str, size_t maxsize) {
if (str == NULL) {
return false;
......@@ -193,11 +194,10 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
tscBuildAndSendRequest(pSql, NULL);
tsem_wait(&pSql->rspSem);
pSql->pTscObj->pClusterInfo = (SClusterInfo *)tscAcquireClusterInfo(pSql->pTscObj->clusterId);
if (pSql->pTscObj->pClusterInfo == NULL) {
assert(pSql->res.code != TSDB_CODE_SUCCESS);
if (0 == strlen(pSql->pTscObj->clusterId)) {
memcpy(pSql->pTscObj->clusterId, clusterDefaultId, strlen(clusterDefaultId));
}
pSql->pTscObj->pClusterInfo = (SClusterInfo *)tscAcquireClusterInfo(pSql->pTscObj->clusterId);
if (pSql->res.code != TSDB_CODE_SUCCESS) {
terrno = pSql->res.code;
if (terrno ==TSDB_CODE_RPC_FQDN_ERROR) {
......
......@@ -134,10 +134,7 @@ void tscClusterInfoDestroy(SClusterInfo *pObj) {
void *tscAcquireClusterInfo(const char *clusterId) {
pthread_mutex_lock(&clusterMutex);
size_t len = strlen(clusterId);
if (len == 0) {
pthread_mutex_unlock(&clusterMutex);
return NULL;
}
SClusterInfo *pObj = NULL;
SClusterInfo **ppObj = taosHashGet(tscClusterMap, clusterId, len);
if (ppObj == NULL || *ppObj == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册