[td-225]fix a race condition.

This commit is contained in:
Haojun Liao 2021-08-07 14:03:30 +08:00
parent b251e7b359
commit b46edae0b1
1 changed files with 9 additions and 6 deletions

View File

@ -256,17 +256,20 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
pQdesc->pid = pHeartbeat->pid; pQdesc->pid = pHeartbeat->pid;
pQdesc->numOfSub = pSql->subState.numOfSub; pQdesc->numOfSub = pSql->subState.numOfSub;
// todo race condition
pQdesc->stableQuery = 0;
char *p = pQdesc->subSqlInfo; char *p = pQdesc->subSqlInfo;
int32_t remainLen = sizeof(pQdesc->subSqlInfo); int32_t remainLen = sizeof(pQdesc->subSqlInfo);
if (pQdesc->numOfSub == 0) { if (pQdesc->numOfSub == 0) {
snprintf(p, remainLen, "N/A"); snprintf(p, remainLen, "N/A");
} else { } else {
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd); // SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd);
if (pQueryInfo != NULL) { // if (pQueryInfo != NULL) {
pQdesc->stableQuery = (pQueryInfo->stableQuery)?1:0; // pQdesc->stableQuery = (pQueryInfo->stableQuery)?1:0;
} else { // } else {
pQdesc->stableQuery = 0; // pQdesc->stableQuery = 0;
} // }
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 < pQdesc->numOfSub; ++i) {