Skip to content

Commit 4070ebd

Browse files
authored
Merge pull request #50242 from thaJeztah/28.x_backport_fix_event_ordering
[28.x backport] daemon: containerStop: fix ordering of "stop" and "die" events
2 parents b613ac4 + 0e0ca09 commit 4070ebd

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

daemon/stop.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func (daemon *Daemon) containerStop(ctx context.Context, ctr *container.Containe
7474
defer func() {
7575
if retErr == nil {
7676
daemon.LogContainerEvent(ctr, events.ActionStop)
77+
// Ensure container status changes are committed by handler of container exit before returning control to the caller
78+
ctr.Lock()
79+
defer ctr.Unlock()
7780
}
7881
}()
7982

@@ -93,9 +96,6 @@ func (daemon *Daemon) containerStop(ctx context.Context, ctr *container.Containe
9396
defer cancel()
9497

9598
if status := <-ctr.Wait(subCtx, containertypes.WaitConditionNotRunning); status.Err() == nil {
96-
// Ensure container status changes are committed by handler of container exit before returning control to the caller
97-
ctr.Lock()
98-
defer ctr.Unlock()
9999
// container did exit, so ignore any previous errors and return
100100
return nil
101101
}
@@ -125,9 +125,5 @@ func (daemon *Daemon) containerStop(ctx context.Context, ctr *container.Containe
125125
// container did exit, so ignore previous errors and continue
126126
}
127127

128-
// Ensure container status changes are committed by handler of container exit before returning control to the caller
129-
ctr.Lock()
130-
defer ctr.Unlock()
131-
132128
return nil
133129
}

0 commit comments

Comments
 (0)