Return number of ping entries, not number of urls processed.

This commit is contained in:
Joachim Bauch 2024-08-28 14:26:49 +02:00
commit 0490cca416
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
2 changed files with 6 additions and 4 deletions

6
hub.go
View file

@ -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)

View file

@ -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) {