提交 529dc19a 编写于 作者: D dapan1121

fix ref issue

上级 a4d4cd2a
...@@ -86,6 +86,7 @@ typedef struct SSchedulerMgmt { ...@@ -86,6 +86,7 @@ typedef struct SSchedulerMgmt {
uint64_t sId; // schedulerId uint64_t sId; // schedulerId
SSchedulerCfg cfg; SSchedulerCfg cfg;
SRWLatch lock; SRWLatch lock;
bool exit;
int32_t jobRef; int32_t jobRef;
int32_t jobNum; int32_t jobNum;
SSchedulerStat stat; SSchedulerStat stat;
......
...@@ -2249,6 +2249,10 @@ int32_t schCancelJob(SSchJob *pJob) { ...@@ -2249,6 +2249,10 @@ int32_t schCancelJob(SSchJob *pJob) {
} }
void schCloseJobRef(void) { void schCloseJobRef(void) {
if (!atomic_load_8((int8_t*)&schMgmt.exit)) {
return;
}
SCH_LOCK(SCH_WRITE, &schMgmt.lock); SCH_LOCK(SCH_WRITE, &schMgmt.lock);
if (atomic_load_32(&schMgmt.jobNum) <= 0 && schMgmt.jobRef >= 0) { if (atomic_load_32(&schMgmt.jobNum) <= 0 && schMgmt.jobRef >= 0) {
taosCloseRef(schMgmt.jobRef); taosCloseRef(schMgmt.jobRef);
...@@ -2390,7 +2394,7 @@ _return: ...@@ -2390,7 +2394,7 @@ _return:
} }
int32_t schedulerInit(SSchedulerCfg *cfg) { int32_t schedulerInit(SSchedulerCfg *cfg) {
if (schMgmt.jobRef) { if (schMgmt.jobRef >= 0) {
qError("scheduler already initialized"); qError("scheduler already initialized");
return TSDB_CODE_QRY_INVALID_INPUT; return TSDB_CODE_QRY_INVALID_INPUT;
} }
...@@ -2754,6 +2758,8 @@ void schedulerFreeTaskList(SArray *taskList) { ...@@ -2754,6 +2758,8 @@ void schedulerFreeTaskList(SArray *taskList) {
} }
void schedulerDestroy(void) { void schedulerDestroy(void) {
atomic_store_8((int8_t*)&schMgmt.exit, 1);
if (schMgmt.jobRef >= 0) { if (schMgmt.jobRef >= 0) {
SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0); SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0);
int64_t refId = 0; int64_t refId = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册