[td-225] fix bugs in free SqlObj in async query module
This commit is contained in:
parent
6c7c4dde96
commit
df41013eca
|
@ -209,6 +209,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
|
||||||
tscError("%p sql is already released", pSql->signature);
|
tscError("%p sql is already released", pSql->signature);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSql->signature != pSql) {
|
if (pSql->signature != pSql) {
|
||||||
tscError("%p sql is already released, signature:%p", pSql, pSql->signature);
|
tscError("%p sql is already released, signature:%p", pSql, pSql->signature);
|
||||||
return;
|
return;
|
||||||
|
@ -217,10 +218,9 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
STscObj *pObj = pSql->pTscObj;
|
STscObj *pObj = pSql->pTscObj;
|
||||||
// tscTrace("%p msg:%s is received from server", pSql, taosMsg[rpcMsg->msgType]);
|
|
||||||
|
|
||||||
if (pObj->signature != pObj || pSql->freed == 1) {
|
if (pObj->signature != pObj || pSql->freed == 1) {
|
||||||
tscTrace("%p sql is already released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed,
|
tscTrace("%p sqlObj needs to be released or DB connection is closed, freed:%d pObj:%p signature:%p", pSql, pSql->freed,
|
||||||
pObj, pObj->signature);
|
pObj, pObj->signature);
|
||||||
tscFreeSqlObj(pSql);
|
tscFreeSqlObj(pSql);
|
||||||
rpcFreeCont(rpcMsg->pCont);
|
rpcFreeCont(rpcMsg->pCont);
|
||||||
|
|
|
@ -219,6 +219,11 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code) {
|
||||||
sem_post(&pSql->rspSem);
|
sem_post(&pSql->rspSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
|
||||||
|
SSqlObj* pSql = (SSqlObj*) tres;
|
||||||
|
sem_post(&pSql->rspSem);
|
||||||
|
}
|
||||||
|
|
||||||
TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) {
|
TAOS_RES* taos_query(TAOS *taos, const char *sqlstr) {
|
||||||
STscObj *pObj = (STscObj *)taos;
|
STscObj *pObj = (STscObj *)taos;
|
||||||
if (pObj == NULL || pObj->signature != pObj) {
|
if (pObj == NULL || pObj->signature != pObj) {
|
||||||
|
@ -369,11 +374,6 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
return (pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows;
|
return (pQueryInfo->order.order == TSDB_ORDER_DESC) ? pRes->numOfRows : -pRes->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
|
|
||||||
SSqlObj* pSql = (SSqlObj*) tres;
|
|
||||||
sem_post(&pSql->rspSem);
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
||||||
SSqlObj *pSql = (SSqlObj *)res;
|
SSqlObj *pSql = (SSqlObj *)res;
|
||||||
if (pSql == NULL || pSql->signature != pSql) {
|
if (pSql == NULL || pSql->signature != pSql) {
|
||||||
|
@ -496,14 +496,14 @@ static bool tscFreeQhandleInVnode(SSqlObj* pSql) {
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
|
|
||||||
// in case of sync model query, waits for response and then goes on
|
// in case of sync model query, waits for response and then goes on
|
||||||
if (pSql->fp == waitForQueryRsp || pSql->fp == waitForRetrieveRsp) {
|
// if (pSql->fp == waitForQueryRsp || pSql->fp == waitForRetrieveRsp) {
|
||||||
sem_wait(&pSql->rspSem);
|
// sem_wait(&pSql->rspSem);
|
||||||
|
|
||||||
tscFreeSqlObj(pSql);
|
// tscFreeSqlObj(pSql);
|
||||||
tscTrace("%p sqlObj is freed by app", pSql);
|
// tscTrace("%p sqlObj is freed by app", pSql);
|
||||||
} else {
|
// } else {
|
||||||
tscTrace("%p sqlObj will be freed while rsp received", pSql);
|
tscTrace("%p sqlObj will be freed while rsp received", pSql);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue