From 6002e200806e6c77617b0337bf4491052e85faeb Mon Sep 17 00:00:00 2001 From: Sense T Date: Sat, 10 Sep 2022 02:19:17 +0000 Subject: [PATCH] safer close --- manager.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/manager.go b/manager.go index 9c149a7..7bd4ef0 100644 --- a/manager.go +++ b/manager.go @@ -47,9 +47,11 @@ func (m *Manager) Run() { m.Connections[connection.ID] = connection m.logger.Tracef("connection '%s' registered", connection.ID) case connection := <-m.delConnection: - connection.Close() - delete(m.Connections, connection.ID) - m.logger.Tracef("connection '%s' unregistered", connection.ID) + if !connection.closed { + connection.Close() + delete(m.Connections, connection.ID) + m.logger.Tracef("connection '%s' unregistered", connection.ID) + } case onReceiveQueue <- true: go m.onReceive(onReceiveQueue) }