Skip to content

Commit

Permalink
resourcemanager: avoid to get nil after task finished when to stop task
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jan 18, 2023
1 parent f268e29 commit ea6891f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions resourcemanager/pooltask/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ func (t *TaskManager[T, U, C, CT, TF]) StopTask(taskID uint64) {
shardID := getShardID(taskID)
t.task[shardID].rw.Lock()
defer t.task[shardID].rw.Unlock()
l := t.task[shardID].stats[taskID].stats
for e := l.Front(); e != nil; e = e.Next() {
e.Value.(tContainer[T, U, C, CT, TF]).task.SetStatus(StopTask)
// When call the StopTask, the task may have been deleted from the manager.
s, ok := t.task[shardID].stats[taskID]
if ok {
l := s.stats
for e := l.Front(); e != nil; e = e.Next() {
e.Value.(tContainer[T, U, C, CT, TF]).task.SetStatus(StopTask)
}
}
}

0 comments on commit ea6891f

Please sign in to comment.