提交 c251cf59 编写于 作者: B Benguang Zhao

fix: resolve an issue of index out-of-range in tscBuildQueryStreamDesc etc.

上级 10bb5d5f
...@@ -283,18 +283,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { ...@@ -283,18 +283,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
// } // }
pthread_mutex_lock(&pSql->subState.mutex); pthread_mutex_lock(&pSql->subState.mutex);
if (pSql->pSubs != NULL && pSql->subState.states != NULL) { if (pSql->pSubs != NULL && pSql->subState.states != NULL) {
for (int32_t i = 0; i < pQdesc->numOfSub; ++i) { for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
// because subState maybe free on anytime by any thread, check validate from here // because subState maybe free on anytime by any thread, check validate from here
if(pSql->subState.numOfSub != pQdesc->numOfSub ||
pSql->pSubs == NULL ||
pSql->subState.states == NULL) {
tscError(" QUERY-HEART STscObj=%p subState maybe free. numOfSub=%d pSubs=%p states=%p",
pObj, pSql->subState.numOfSub, pSql->pSubs, pSql->subState.states);
pQdesc->numOfSub = 0;
// break for
break;
}
SSqlObj *psub = pSql->pSubs[i]; SSqlObj *psub = pSql->pSubs[i];
int64_t self = (psub != NULL)? psub->self : 0; int64_t self = (psub != NULL)? psub->self : 0;
...@@ -307,6 +297,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) { ...@@ -307,6 +297,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
p += len; p += len;
} }
} }
pQdesc->numOfSub = pSql->subState.numOfSub;
pthread_mutex_unlock(&pSql->subState.mutex); pthread_mutex_unlock(&pSql->subState.mutex);
} }
......
...@@ -357,7 +357,7 @@ void checkBrokenQueries(STscObj *pTscObj) { ...@@ -357,7 +357,7 @@ void checkBrokenQueries(STscObj *pTscObj) {
pthread_mutex_lock(&pSql->subState.mutex); pthread_mutex_lock(&pSql->subState.mutex);
if (pSql->pSubs) { if (pSql->pSubs) {
// have sub sql // have sub sql
for (int i = 0; i < numOfSub; i++) { for (int i = 0; i < pSql->subState.numOfSub; i++) {
SSqlObj *pSubSql = pSql->pSubs[i]; SSqlObj *pSubSql = pSql->pSubs[i];
if(pSubSql) { if(pSubSql) {
tscInfo("PROBE 0x%" PRIx64 " sub sql app is 0x%" PRIx64, pSql->self, pSubSql->self); tscInfo("PROBE 0x%" PRIx64 " sub sql app is 0x%" PRIx64, pSql->self, pSubSql->self);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册