Skip to content

Commit

Permalink
Fix concurrent access on task returnError
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Sep 30, 2023
1 parent 63b82af commit e727641
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions common/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ func (g *Group) RunContextList(contextList []context.Context) error {
}

selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList...))
if selectedContext != 0 {
returnError = E.Append(returnError, upstreamErr, func(err error) error {
return E.Cause(err, "upstream")
})
}

if g.cleanup != nil {
g.cleanup()
}

<-taskContext.Done()

if selectedContext != 0 {
returnError = E.Append(returnError, upstreamErr, func(err error) error {
return E.Cause(err, "upstream")
})
}

return returnError
}

0 comments on commit e727641

Please sign in to comment.