1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-23 19:40:54 +00:00

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

View File

@ -452,9 +452,11 @@ func (m *taskManager) StartTask() {
func (m *taskManager) run() { func (m *taskManager) run() {
now := time.Now().Local() now := time.Now().Local()
m.taskLock.Lock()
for _, t := range m.adminTaskList { for _, t := range m.adminTaskList {
t.SetNext(nil, now) t.SetNext(nil, now)
} }
m.taskLock.Unlock()
for { for {
// we only use RLock here because NewMapSorter copy the reference, do not change any thing // we only use RLock here because NewMapSorter copy the reference, do not change any thing