From d01239e2ed0440f22a2ee158741409bdb5039ed8 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 8 Dec 2024 11:11:36 +0100 Subject: [PATCH] fix: gcConnOnError() * better removal of connections --- src/ws/init.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ws/init.go b/src/ws/init.go index e6993ff..cc5e526 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -44,11 +44,14 @@ func welcomeAgents(ws *websocket.Conn, welcome wsWelcome, t string) { func gcConnOnError(ws *websocket.Conn) (err error) { listeners.Range(func(index, value interface{}) bool { - if value.(*connectionInfo).ConnectionPS == ws || value.(*connectionInfo).ConnectionRR == ws { - value.(*connectionInfo).ConnectionPS.Close() - value.(*connectionInfo).ConnectionRR.Close() - listeners.Delete(index) + var ci = value.(*connectionInfo) + if ci.ConnectionPS == ws { + ci.ConnectionPS.Close() } + if ci.ConnectionRR == ws { + ci.ConnectionRR.Close() + } + listeners.Delete(index) return true }) return err