diff --git a/libpod/runtime.go b/libpod/runtime.go index 7ad2c23bbf..565a74645e 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -613,6 +613,11 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) { // refresh runs. runtime.valid = true + // Setup the worker channel early to start accepting jobs from refresh, + // but do not start to execute the jobs right away. The runtime is not + // ready at this point. + runtime.setupWorkerQueue() + // If we need to refresh the state, do it now - things are guaranteed to // be set up by now. if doRefresh { diff --git a/libpod/runtime_worker.go b/libpod/runtime_worker.go index 20e1f4e7d1..484e1ffe0a 100644 --- a/libpod/runtime_worker.go +++ b/libpod/runtime_worker.go @@ -2,8 +2,11 @@ package libpod -func (r *Runtime) startWorker() { +func (r *Runtime) setupWorkerQueue() { r.workerChannel = make(chan func(), 10) +} + +func (r *Runtime) startWorker() { go func() { for w := range r.workerChannel { w()