summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-05-26 09:27:24 +0200
committerValentin Rothberg <rothberg@redhat.com>2021-05-26 09:28:44 +0200
commitd1c9e034ff2d1570f87bcba6d8fa555752e6d6e0 (patch)
tree9f40c3e864631fde1c41b0283ab1fe60eee3688c /libpod/runtime.go
parentd0f5796c3975dea3e26e0f50d8111d4be6d5a963 (diff)
downloadpodman-d1c9e034ff2d1570f87bcba6d8fa555752e6d6e0.tar.gz
podman-d1c9e034ff2d1570f87bcba6d8fa555752e6d6e0.tar.bz2
podman-d1c9e034ff2d1570f87bcba6d8fa555752e6d6e0.zip
libimage-events channel: fix data race
Fix a data race between creating and using the libimage-events channel. [NO TESTS NEEDED] since it really depends on the scheduler and we couldn't hit the race so far. Fixes: #10459 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 713026a9e..e551e6fe8 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -217,8 +217,6 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
return nil, err
}
- runtime.libimageEventsShutdown = make(chan bool)
-
return runtime, nil
}
@@ -701,6 +699,8 @@ var libimageEventsMap = map[libimage.EventType]events.Status{
// events on the libimage.Runtime. The gourtine will be cleaned up implicitly
// when the main() exists.
func (r *Runtime) libimageEvents() {
+ r.libimageEventsShutdown = make(chan bool)
+
toLibpodEventStatus := func(e *libimage.Event) events.Status {
status, found := libimageEventsMap[e.Type]
if !found {
@@ -780,7 +780,9 @@ func (r *Runtime) Shutdown(force bool) error {
// attempt to shut it down
if r.store != nil {
// Wait for the events to be written.
- r.libimageEventsShutdown <- true
+ if r.libimageEventsShutdown != nil {
+ r.libimageEventsShutdown <- true
+ }
// Note that the libimage runtime shuts down the store.
if err := r.libimageRuntime.Shutdown(force); err != nil {