mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
tasklist: fix consumer deadlock
This commit is contained in:
@@ -187,7 +187,6 @@ func (list *List) GetTaskReturnValueByID(ID int) (*ProcessReturnValue, error) {
|
||||
// become available.
|
||||
func (list *List) RunTaskInBackground(name string, resources []string, process Process) (Task, *ResourceConflictError) {
|
||||
list.Lock()
|
||||
defer list.Unlock()
|
||||
|
||||
list.idCounter++
|
||||
wgTask := &sync.WaitGroup{}
|
||||
@@ -204,7 +203,11 @@ func (list *List) RunTaskInBackground(name string, resources []string, process P
|
||||
tasks := list.usedResources.UsedBy(resources)
|
||||
if len(tasks) == 0 {
|
||||
list.usedResources.MarkInUse(task.resources, task)
|
||||
// queueing task might block if channel not ready, unlock list before queueing
|
||||
list.Unlock()
|
||||
list.queue <- task
|
||||
} else {
|
||||
list.Unlock()
|
||||
}
|
||||
|
||||
return *task, nil
|
||||
|
||||
Reference in New Issue
Block a user