From 0490cca416df89f805e4573e17a36534ed463c2a Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 28 Aug 2024 14:26:49 +0200 Subject: [PATCH] Return number of ping entries, not number of urls processed. --- hub.go | 6 +++--- room.go | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hub.go b/hub.go index d7e1872..552851f 100644 --- a/hub.go +++ b/hub.go @@ -1717,8 +1717,9 @@ func (h *Hub) publishFederatedSessions() (int, *sync.WaitGroup) { h.mu.RLock() defer h.mu.RUnlock() + var wg sync.WaitGroup if len(h.federatedSessions) == 0 { - return 0, nil + return 0, &wg } rooms := make(map[string]map[string][]BackendPingEntry) @@ -1766,15 +1767,14 @@ func (h *Hub) publishFederatedSessions() (int, *sync.WaitGroup) { }) } - var wg sync.WaitGroup if len(urls) == 0 { return 0, &wg } count := 0 for roomId, entries := range rooms { - count += len(entries) for u, e := range entries { wg.Add(1) + count += len(e) go func(roomId string, url *url.URL, entries []BackendPingEntry) { defer wg.Done() ctx, cancel := context.WithTimeout(context.Background(), h.backendTimeout) diff --git a/room.go b/room.go index 35047d0..19a9ff5 100644 --- a/room.go +++ b/room.go @@ -956,8 +956,10 @@ func (r *Room) publishActiveSessions() (int, *sync.WaitGroup) { if len(urls) == 0 { return 0, &wg } + var count int for u, e := range entries { wg.Add(1) + count += len(e) go func(url *url.URL, entries []BackendPingEntry) { defer wg.Done() ctx, cancel := context.WithTimeout(context.Background(), r.hub.backendTimeout) @@ -968,7 +970,7 @@ func (r *Room) publishActiveSessions() (int, *sync.WaitGroup) { } }(urls[u], e) } - return len(entries), &wg + return count, &wg } func (r *Room) publishRoomMessage(message *BackendRoomMessageRequest) {