Fix deadlock when task's exec start fails
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
19
io.go
19
io.go
@@ -1,6 +1,7 @@
|
||||
package containerd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -18,6 +19,13 @@ type IO struct {
|
||||
closer *wgCloser
|
||||
}
|
||||
|
||||
func (i *IO) Cancel() {
|
||||
if i.closer == nil {
|
||||
return
|
||||
}
|
||||
i.closer.Cancel()
|
||||
}
|
||||
|
||||
func (i *IO) Wait() {
|
||||
if i.closer == nil {
|
||||
return
|
||||
@@ -134,9 +142,10 @@ type ioSet struct {
|
||||
}
|
||||
|
||||
type wgCloser struct {
|
||||
wg *sync.WaitGroup
|
||||
dir string
|
||||
set []io.Closer
|
||||
wg *sync.WaitGroup
|
||||
dir string
|
||||
set []io.Closer
|
||||
cancel context.CancelFunc
|
||||
}
|
||||
|
||||
func (g *wgCloser) Wait() {
|
||||
@@ -152,3 +161,7 @@ func (g *wgCloser) Close() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *wgCloser) Cancel() {
|
||||
g.cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user