File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -722,9 +722,10 @@ func (r *Runtime) libimageEvents() {
722
722
723
723
eventChannel := r .libimageRuntime .EventChannel ()
724
724
go func () {
725
+ sawShutdown := false
725
726
for {
726
727
// Make sure to read and write all events before
727
- // checking if we're about to shutdown .
728
+ // shutting down .
728
729
for len (eventChannel ) > 0 {
729
730
libimageEvent := <- eventChannel
730
731
e := events.Event {
@@ -739,12 +740,15 @@ func (r *Runtime) libimageEvents() {
739
740
}
740
741
}
741
742
742
- select {
743
- case <- r .libimageEventsShutdown :
743
+ if sawShutdown {
744
+ close ( r .libimageEventsShutdown )
744
745
return
746
+ }
745
747
746
- default :
747
- time .Sleep (100 * time .Millisecond )
748
+ select {
749
+ case <- r .libimageEventsShutdown :
750
+ sawShutdown = true
751
+ case <- time .After (100 * time .Millisecond ):
748
752
}
749
753
}
750
754
}()
@@ -793,7 +797,10 @@ func (r *Runtime) Shutdown(force bool) error {
793
797
if r .store != nil {
794
798
// Wait for the events to be written.
795
799
if r .libimageEventsShutdown != nil {
800
+ // Tell loop to shutdown
796
801
r .libimageEventsShutdown <- true
802
+ // Wait for close to signal shutdown
803
+ <- r .libimageEventsShutdown
797
804
}
798
805
799
806
// Note that the libimage runtime shuts down the store.
You can’t perform that action at this time.
0 commit comments