提交 9c7b14b7 编写于 作者: P Ping Xiao

TD-2652

上级 95b8d347
......@@ -89,12 +89,17 @@ int taosInitTimer(void (*callback)(int), int ms) {
if (code != 0) {
uError("failed to create timer thread");
return -1;
} else {
uDebug("timer thread:0x%08" PRIx64 " is created", taosGetPthreadId(timerThread));
}
return 0;
}
void taosUninitTimer() {
stopTimer = true;
uDebug("join timer thread:0x%08" PRIx64, taosGetPthreadId(timerThread));
pthread_join(timerThread, NULL);
}
......
......@@ -292,6 +292,9 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
if (pthread_create(&newScript->bgPid, NULL, simExecuteScript, (void *)newScript) != 0) {
sprintf(script->error, "lineNum:%d. create background thread failed", script->lines[script->linePos].lineNum);
return false;
} else {
simDebug("script:%s, background thread:0x%08" PRIx64 " is created", newScript->fileName,
taosGetPthreadId(newScript->bgPid));
}
script->linePos++;
......
......@@ -93,23 +93,30 @@ void simFreeScript(SScript *script) {
for (int32_t i = 0; i < script->bgScriptLen; ++i) {
SScript *bgScript = script->bgScripts[i];
simInfo("script:%s, set stop flag", script->fileName);
simDebug("script:%s, is background script, set stop flag", bgScript->fileName);
bgScript->killed = true;
if (taosCheckPthreadValid(bgScript->bgPid)) {
pthread_join(bgScript->bgPid, NULL);
}
simDebug("script:%s, background thread joined", bgScript->fileName);
taos_close(bgScript->taos);
tfree(bgScript->lines);
tfree(bgScript->optionBuffer);
tfree(bgScript);
}
}
simDebug("script:%s, is freed", script->fileName);
taos_close(script->taos);
tfree(script->lines);
tfree(script->optionBuffer);
tfree(script);
simDebug("script:%s, is cleaned", script->fileName);
taos_close(script->taos);
tfree(script->lines);
tfree(script->optionBuffer);
tfree(script);
}
}
SScript *simProcessCallOver(SScript *script) {
if (script->type == SIM_SCRIPT_TYPE_MAIN) {
simDebug("script:%s, is main script, set stop flag", script->fileName);
if (script->killed) {
simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s",
script->fileName, script->error);
......@@ -131,7 +138,7 @@ SScript *simProcessCallOver(SScript *script) {
return simScriptList[simScriptPos];
}
} else {
simInfo("script:%s, is stopped by main script", script->fileName);
simDebug("script:%s, is stopped", script->fileName);
simFreeScript(script);
return NULL;
}
......@@ -161,5 +168,6 @@ void *simExecuteScript(void *inputScript) {
}
}
simInfo("thread is stopped");
return NULL;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册