td-1089: fix memory leak and invalid read
This commit is contained in:
parent
1d7626df1c
commit
941705c5d6
|
@ -230,6 +230,7 @@ int32_t tscAddSubqueryInfo(SSqlCmd *pCmd);
|
||||||
void tscInitQueryInfo(SQueryInfo* pQueryInfo);
|
void tscInitQueryInfo(SQueryInfo* pQueryInfo);
|
||||||
|
|
||||||
void tscClearSubqueryInfo(SSqlCmd* pCmd);
|
void tscClearSubqueryInfo(SSqlCmd* pCmd);
|
||||||
|
void tscFreeVgroupTableInfo(SArray* pVgroupTables);
|
||||||
|
|
||||||
int tscGetSTableVgroupInfo(SSqlObj* pSql, int32_t clauseIndex);
|
int tscGetSTableVgroupInfo(SSqlObj* pSql, int32_t clauseIndex);
|
||||||
int tscGetTableMeta(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo);
|
int tscGetTableMeta(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo);
|
||||||
|
|
|
@ -230,6 +230,19 @@ static SArray* getTableList( SSqlObj* pSql ) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t compareTidTag(const void* p1, const void* p2) {
|
||||||
|
const STidTags* t1 = (const STidTags*)p1;
|
||||||
|
const STidTags* t2 = (const STidTags*)p2;
|
||||||
|
|
||||||
|
if (t1->vgId != t2->vgId) {
|
||||||
|
return (t1->vgId > t2->vgId) ? 1 : -1;
|
||||||
|
}
|
||||||
|
if (t1->tid != t2->tid) {
|
||||||
|
return (t1->tid > t2->tid) ? 1 : -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
|
static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
|
||||||
SSqlObj* pSql = pSub->pSql;
|
SSqlObj* pSql = pSub->pSql;
|
||||||
|
@ -270,7 +283,8 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
|
||||||
pSub->progress = progress;
|
pSub->progress = progress;
|
||||||
|
|
||||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||||
taosArraySort( tables, tscCompareTidTags );
|
taosArraySort( tables, compareTidTag );
|
||||||
|
tscFreeVgroupTableInfo(pTableMetaInfo->pVgroupTables);
|
||||||
tscBuildVgroupTableInfo(pSql, pTableMetaInfo, tables);
|
tscBuildVgroupTableInfo(pSql, pTableMetaInfo, tables);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(tables);
|
taosArrayDestroy(tables);
|
||||||
|
|
|
@ -1556,12 +1556,22 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
|
||||||
|
if (pVgroupTables != NULL) {
|
||||||
|
for (size_t i = 0; i < taosArrayGetSize(pVgroupTables); i++) {
|
||||||
|
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i);
|
||||||
|
taosArrayDestroy(pInfo->itemList);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pVgroupTables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) {
|
void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) {
|
||||||
tscDebug("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables);
|
tscDebug("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables);
|
||||||
|
|
||||||
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
|
||||||
|
tscFreeVgroupTableInfo(pTableMetaInfo->pVgroupTables);
|
||||||
tscClearTableMetaInfo(pTableMetaInfo, removeFromCache);
|
tscClearTableMetaInfo(pTableMetaInfo, removeFromCache);
|
||||||
free(pTableMetaInfo);
|
free(pTableMetaInfo);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue