aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-10-07 13:16:56 +0200
committerGitHub <noreply@github.com>2022-10-07 13:16:56 +0200
commit2062ab9db4d59623e56dd58169735d9fba1c0838 (patch)
treedfcfd66ff5eb2eae5d527e1af497d056808ecf18
parentd33a31524a275245b9535871208a2858ba517ed0 (diff)
parent5b71070e421b7491bfc9046dea1ae94888cbb6d4 (diff)
downloadpodman-2062ab9db4d59623e56dd58169735d9fba1c0838.tar.gz
podman-2062ab9db4d59623e56dd58169735d9fba1c0838.tar.bz2
podman-2062ab9db4d59623e56dd58169735d9fba1c0838.zip
Merge pull request #16072 from alexlarsson/events-shutdown-nosleep
libpod: Remove 100msec delay during shutdown
-rw-r--r--libpod/runtime.go17
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.