1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 01:10:54 +00:00

fix deadlock in task module

This commit is contained in:
Anker Jam 2020-10-05 00:16:58 +08:00
parent c5d43e87fe
commit 4dc694411f

View File

@ -451,6 +451,11 @@ func run() {
taskLock.Unlock()
continue
case <-stop:
taskLock.Lock()
if isstart {
isstart = false
}
taskLock.Unlock()
return
}
}
@ -458,15 +463,9 @@ func run() {
// StopTask stop all tasks
func StopTask() {
taskLock.Lock()
defer taskLock.Unlock()
if isstart {
isstart = false
stop <- true
}
}
// AddTask add task with name
func AddTask(taskname string, t Tasker) {
taskLock.Lock()