From 65665ab807513547062244bd57eebe0f94ab12d0 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 7 Dec 2017 16:03:00 -0500 Subject: [PATCH] Always Cancel before Close Document this contract. Signed-off-by: Daniel Nephin --- cio/io.go | 7 ++++--- process.go | 1 + task.go | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cio/io.go b/cio/io.go index 25e398147..c5e112d9c 100644 --- a/cio/io.go +++ b/cio/io.go @@ -24,11 +24,12 @@ type Config struct { type IO interface { // Config returns the IO configuration. Config() Config - // Cancel aborts all current io operations + // Cancel aborts all current io operations. Cancel() - // Wait blocks until all io copy operations have completed + // Wait blocks until all io copy operations have completed. Wait() - // Close cleans up all open io resources + // Close cleans up all open io resources. Cancel() is always called before + // Close() Close() error } diff --git a/process.go b/process.go index ad1a2a1f4..32049cf07 100644 --- a/process.go +++ b/process.go @@ -191,6 +191,7 @@ func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitS return nil, errdefs.FromGRPC(err) } if p.io != nil { + p.io.Cancel() p.io.Wait() p.io.Close() } diff --git a/task.go b/task.go index 8d256834f..28f49fa6c 100644 --- a/task.go +++ b/task.go @@ -163,6 +163,7 @@ func (t *task) Start(ctx context.Context) error { ContainerID: t.id, }) if err != nil { + t.io.Cancel() t.io.Close() return errdefs.FromGRPC(err) }