From 4ac4fd0b6a268fe6f38b2b2e32e40daa7e424fac Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Fri, 23 Feb 2018 22:30:09 +0000 Subject: [PATCH] Close io after task deletion to avoid race condition. Signed-off-by: Lantao Liu --- task.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/task.go b/task.go index 4421eb006..f801d493d 100644 --- a/task.go +++ b/task.go @@ -283,7 +283,6 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat if t.io != nil { t.io.Cancel() t.io.Wait() - t.io.Close() } r, err := t.client.TaskService().Delete(ctx, &tasks.DeleteTaskRequest{ ContainerID: t.id, @@ -291,6 +290,10 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat if err != nil { return nil, errdefs.FromGRPC(err) } + // Only cleanup the IO after a successful Delete + if t.io != nil { + t.io.Close() + } return &ExitStatus{code: r.ExitStatus, exitedAt: r.ExitedAt}, nil }