Merge pull request #4306 from AllenX2018/fix-issue-4305

fix issue #4305: add write lock for map adminTaskList iteration and modify
This commit is contained in:
Ming Deng 2020-11-11 20:52:29 +08:00 committed by GitHub
commit 8f16098508
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -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