From da6a2ee92f3ab031d6f9c64eaae58addae28b2c4 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Mon, 9 Oct 2023 11:28:50 -0400 Subject: [PATCH] Pass clnt as a parameter to the goroutine in syncSessions This prevents the clnt loop variable to be captured by the func literal. --- sessions/sessions.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sessions/sessions.go b/sessions/sessions.go index 896100853..096a317d6 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1379,9 +1379,9 @@ func (sS *SessionS) syncSessions() { for _, clnt := range sS.biJClients() { wg.Add(1) - go func() { // query all connections at once + go func(c *biJClient) { // query all connections at once var queriedSessionIDs []*SessionID - if err := clnt.conn.Call(context.TODO(), utils.SessionSv1GetActiveSessionIDs, + if err := c.conn.Call(context.TODO(), utils.SessionSv1GetActiveSessionIDs, utils.EmptyString, &queriedSessionIDs); err != nil && err.Error() != utils.ErrNoActiveSession.Error() { utils.Logger.Warning( @@ -1392,7 +1392,7 @@ func (sS *SessionS) syncSessions() { queriedCGRIDs.Set(sessionID.CGRID(), struct{}{}) } wg.Done() - }() + }(clnt) } wg.Wait() // wait for all clients to finish in one way or another