From aad80ba4fad57dcd124203fe0128f662af52cf91 Mon Sep 17 00:00:00 2001 From: AllenX2018 Date: Wed, 11 Nov 2020 17:14:05 +0800 Subject: [PATCH] fix issue#4305: add write lock for map adminTaskList iteration and modify --- task/task.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/task/task.go b/task/task.go index 8f25a0f3..00cbbfa7 100644 --- a/task/task.go +++ b/task/task.go @@ -452,9 +452,11 @@ func (m *taskManager) StartTask() { func (m *taskManager) run() { now := time.Now().Local() + m.taskLock.Lock() for _, t := range m.adminTaskList { t.SetNext(nil, now) } + m.taskLock.Unlock() for { // we only use RLock here because NewMapSorter copy the reference, do not change any thing