Remove federated session from internal map on cleanup.

This commit is contained in:
Joachim Bauch 2025-11-04 14:12:59 +01:00
commit 91b29d4103
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
2 changed files with 4 additions and 1 deletions

1
hub.go
View file

@ -824,6 +824,7 @@ func (h *Hub) removeSession(session Session) (removed bool) {
}
delete(h.expiredSessions, session)
if session, ok := session.(*ClientSession); ok {
delete(h.federatedSessions, session)
delete(h.anonymousSessions, session)
delete(h.dialoutSessions, session)
}

View file

@ -286,6 +286,7 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) {
clients := len(h.clients)
sessions := len(h.sessions)
remoteSessions := len(h.remoteSessions)
federatedSessions := len(h.federatedSessions)
h.mu.Unlock()
h.ru.Lock()
rooms := len(h.rooms)
@ -296,6 +297,7 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) {
rooms == 0 &&
sessions == 0 &&
remoteSessions == 0 &&
federatedSessions == 0 &&
readActive == 0 &&
writeActive == 0 {
break
@ -306,7 +308,7 @@ func WaitForHub(ctx context.Context, t *testing.T, h *Hub) {
h.mu.Lock()
h.ru.Lock()
dumpGoroutines("", os.Stderr)
assert.Fail(t, "Error waiting for hub to terminate", "clients %+v / rooms %+v / sessions %+v / remoteSessions %v / %d read / %d write: %s", h.clients, h.rooms, h.sessions, h.remoteSessions, readActive, writeActive, ctx.Err())
assert.Fail(t, "Error waiting for hub to terminate", "clients %+v / rooms %+v / sessions %+v / remoteSessions %v / federatedSessions %v / %d read / %d write: %s", h.clients, h.rooms, h.sessions, remoteSessions, federatedSessions, readActive, writeActive, ctx.Err())
h.ru.Unlock()
h.mu.Unlock()
return