Merge pull request #1894 from dnephin/cio-cancel-close

Always IO.Cancel() before IO.Close()
This commit is contained in:
Phil Estes 2017-12-08 12:38:51 -05:00 committed by GitHub
commit 6393165b09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -24,11 +24,12 @@ type Config struct {
type IO interface { type IO interface {
// Config returns the IO configuration. // Config returns the IO configuration.
Config() Config Config() Config
// Cancel aborts all current io operations // Cancel aborts all current io operations.
Cancel() Cancel()
// Wait blocks until all io copy operations have completed // Wait blocks until all io copy operations have completed.
Wait() Wait()
// Close cleans up all open io resources // Close cleans up all open io resources. Cancel() is always called before
// Close()
Close() error Close() error
} }

View File

@ -191,6 +191,7 @@ func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitS
return nil, errdefs.FromGRPC(err) return nil, errdefs.FromGRPC(err)
} }
if p.io != nil { if p.io != nil {
p.io.Cancel()
p.io.Wait() p.io.Wait()
p.io.Close() p.io.Close()
} }

View File

@ -163,6 +163,7 @@ func (t *task) Start(ctx context.Context) error {
ContainerID: t.id, ContainerID: t.id,
}) })
if err != nil { if err != nil {
t.io.Cancel()
t.io.Close() t.io.Close()
return errdefs.FromGRPC(err) return errdefs.FromGRPC(err)
} }