Skip to content

Commit a216d3d

Browse files
committed
oci: always close chControl
Signed-off-by: Peter Hunt <[email protected]>
1 parent 1e8e40a commit a216d3d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal/oci/oci.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func (r *Runtime) WaitContainerStateStopped(ctx context.Context, c *Container) e
128128

129129
done := make(chan error, 1)
130130
chControl := make(chan struct{}, 1)
131+
defer close(chControl)
131132
go func() {
132133
defer close(done)
133134
for {
@@ -152,10 +153,8 @@ func (r *Runtime) WaitContainerStateStopped(ctx context.Context, c *Container) e
152153
case err = <-done:
153154
break
154155
case <-ctx.Done():
155-
close(chControl)
156156
return ctx.Err()
157157
case <-time.After(time.Duration(r.config.CtrStopTimeout) * time.Second):
158-
close(chControl)
159158
return fmt.Errorf(
160159
"failed to get container stopped status: %ds timeout reached",
161160
r.config.CtrStopTimeout,

0 commit comments

Comments
 (0)