diff options
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r-- | libpod/runtime.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index f250d759c..0828c19d5 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -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{ @@ -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): } } }() @@ -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. |