Skip to content

Commit

Permalink
Merge pull request #22345 from taosdata/fix/main-TD-25606
Browse files Browse the repository at this point in the history
fix: memory leak
  • Loading branch information
plum-lihui committed Aug 7, 2023
2 parents 90e2d5e + 661f2ac commit 6ac7ccf
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions source/dnode/vnode/src/tsdb/tsdbFS2.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,19 +780,20 @@ static int32_t tsdbFSRunBgTask(void *arg) {
return 0;
}

static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *), void (*free)(void *),
void *arg, int64_t *taskid) {
static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *),
void (*destroy)(void *), void *arg, int64_t *taskid) {
if (fs->stop) {
if (destroy) {
destroy(arg);
}
return 0; // TODO: use a better error code
}

// check if same task is on
// if (fs->bgTaskRunning && fs->bgTaskRunning->type == type) {
// return 0;
// }

for (STFSBgTask *task = fs->bgTaskQueue->next; task != fs->bgTaskQueue; task = task->next) {
if (task->type == type) {
if (destroy) {
destroy(arg);
}
return 0;
}
}
Expand All @@ -804,7 +805,7 @@ static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32

task->type = type;
task->run = run;
task->free = free;
task->free = destroy;
task->arg = arg;
task->scheduleTime = taosGetTimestampMs();
task->taskid = ++fs->taskid;
Expand Down

0 comments on commit 6ac7ccf

Please sign in to comment.