Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpod: Remove 100msec delay during shutdown #16072

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,10 @@ func (r *Runtime) libimageEvents() {

eventChannel := r.libimageRuntime.EventChannel()
go func() {
sawShutdown := false
for {
// Make sure to read and write all events before
// checking if we're about to shutdown.
// shutting down.
for len(eventChannel) > 0 {
libimageEvent := <-eventChannel
e := events.Event{
Expand All @@ -739,12 +740,15 @@ func (r *Runtime) libimageEvents() {
}
}

select {
case <-r.libimageEventsShutdown:
if sawShutdown {
close(r.libimageEventsShutdown)
return
}

default:
time.Sleep(100 * time.Millisecond)
select {
case <-r.libimageEventsShutdown:
sawShutdown = true
case <-time.After(100 * time.Millisecond):
}
}
}()
Expand Down Expand Up @@ -793,7 +797,10 @@ func (r *Runtime) Shutdown(force bool) error {
if r.store != nil {
// Wait for the events to be written.
if r.libimageEventsShutdown != nil {
// Tell loop to shutdown
r.libimageEventsShutdown <- true
// Wait for close to signal shutdown
<-r.libimageEventsShutdown
}

// Note that the libimage runtime shuts down the store.
Expand Down