mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
Merge pull request #16072 from alexlarsson/events-shutdown-nosleep
libpod: Remove 100msec delay during shutdown
This commit is contained in:
@ -722,9 +722,10 @@ func (r *Runtime) libimageEvents() {
|
|||||||
|
|
||||||
eventChannel := r.libimageRuntime.EventChannel()
|
eventChannel := r.libimageRuntime.EventChannel()
|
||||||
go func() {
|
go func() {
|
||||||
|
sawShutdown := false
|
||||||
for {
|
for {
|
||||||
// Make sure to read and write all events before
|
// Make sure to read and write all events before
|
||||||
// checking if we're about to shutdown.
|
// shutting down.
|
||||||
for len(eventChannel) > 0 {
|
for len(eventChannel) > 0 {
|
||||||
libimageEvent := <-eventChannel
|
libimageEvent := <-eventChannel
|
||||||
e := events.Event{
|
e := events.Event{
|
||||||
@ -739,12 +740,15 @@ func (r *Runtime) libimageEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sawShutdown {
|
||||||
|
close(r.libimageEventsShutdown)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-r.libimageEventsShutdown:
|
case <-r.libimageEventsShutdown:
|
||||||
return
|
sawShutdown = true
|
||||||
|
case <-time.After(100 * time.Millisecond):
|
||||||
default:
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -793,7 +797,10 @@ func (r *Runtime) Shutdown(force bool) error {
|
|||||||
if r.store != nil {
|
if r.store != nil {
|
||||||
// Wait for the events to be written.
|
// Wait for the events to be written.
|
||||||
if r.libimageEventsShutdown != nil {
|
if r.libimageEventsShutdown != nil {
|
||||||
|
// Tell loop to shutdown
|
||||||
r.libimageEventsShutdown <- true
|
r.libimageEventsShutdown <- true
|
||||||
|
// Wait for close to signal shutdown
|
||||||
|
<-r.libimageEventsShutdown
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that the libimage runtime shuts down the store.
|
// Note that the libimage runtime shuts down the store.
|
||||||
|
Reference in New Issue
Block a user