1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

make sure err is propagated

This commit is contained in:
Darien Raymond 2018-08-05 17:56:49 +02:00
parent 8d7fab6aea
commit 8ed119e3f6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -88,8 +88,8 @@ func OnFailure(task Task) ExecutionOption {
}
}
func Single(task Task, opts ExecutionOption) Task {
return Run(append([]ExecutionOption{Sequential(task)}, opts)...)
func Single(task Task, opts ...ExecutionOption) Task {
return Run(append([]ExecutionOption{Sequential(task)}, opts...)...)
}
func Run(opts ...ExecutionOption) Task {
@ -120,14 +120,17 @@ func executeParallel(ctx context.Context, tasks []Task) error {
for _, task := range tasks {
<-s.Wait()
go func(f func() error) {
if err := f(); err != nil {
select {
case done <- err:
default:
}
go func(f Task) {
err := f()
if err == nil {
s.Signal()
return
}
select {
case done <- err:
default:
}
s.Signal()
}(task)
}