diff --git a/protocol/connections/engine.go b/protocol/connections/engine.go index 0cff804..30529d5 100644 --- a/protocol/connections/engine.go +++ b/protocol/connections/engine.go @@ -145,15 +145,17 @@ func (e *engine) createPeerTemplate() *PeerApp { // Listen sets up an onion listener to process incoming cwtch messages func (e *engine) listenFn() { err := e.service.Listen(e.createPeerTemplate()) - e.eventManager.Publish(event.NewEvent(event.ProtocolEngineStopped, map[event.Field]string{event.Identity: e.identity.Hostname(), event.Error: err.Error()})) + if !e.shuttingDown { + e.eventManager.Publish(event.NewEvent(event.ProtocolEngineStopped, map[event.Field]string{event.Identity: e.identity.Hostname(), event.Error: err.Error()})) + } return } // Shutdown tears down the eventHandler goroutine func (e *engine) Shutdown() { e.shuttingDown = true - e.service.Shutdown() e.connectionsManager.Shutdown() + e.service.Shutdown() e.queue.Shutdown() }