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

TD-2652

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