diff --git a/internals/overlord/servstate/handlers.go b/internals/overlord/servstate/handlers.go index 4fcbf3d8..2db5f6cc 100644 --- a/internals/overlord/servstate/handlers.go +++ b/internals/overlord/servstate/handlers.go @@ -280,7 +280,11 @@ func (m *ServiceManager) serviceForStop(task *state.Task, name string) *serviceD func (m *ServiceManager) removeService(name string) { m.servicesLock.Lock() defer m.servicesLock.Unlock() + m.removeServiceInternal(name) +} +// not concurrency-safe, please lock m.servicesLock before calling +func (m *ServiceManager) removeServiceInternal(name string) { svc, svcExists := m.services[name] if !svcExists { return diff --git a/internals/overlord/servstate/manager.go b/internals/overlord/servstate/manager.go index 0e3f193d..f85bfeb5 100644 --- a/internals/overlord/servstate/manager.go +++ b/internals/overlord/servstate/manager.go @@ -88,8 +88,12 @@ func (m *ServiceManager) Stop() { if err != nil { logger.Noticef("Cannot stop child process reaper: %v", err) } + + // Close all the service ringbuffers + m.servicesLock.Lock() + defer m.servicesLock.Unlock() for name := range m.services { - m.removeService(name) + m.removeServiceInternal(name) } }