use relay manager.getClientLen()

This commit is contained in:
Maycon Santos
2025-07-20 21:31:59 +02:00
parent 84988b4d53
commit bdb38dfa57
2 changed files with 8 additions and 2 deletions

View File

@@ -350,6 +350,12 @@ func (m *Manager) startCleanupLoop() {
}
}
func (m *Manager) getClientLen() int {
m.relayClientsMutex.Lock()
defer m.relayClientsMutex.Unlock()
return len(m.relayClients)
}
func (m *Manager) cleanUpUnusedRelays() {
m.relayClientsMutex.Lock()
defer m.relayClientsMutex.Unlock()

View File

@@ -292,8 +292,8 @@ func TestForeginAutoClose(t *testing.T) {
timeout := relayCleanupInterval + keepUnusedServerTime + 1*time.Second
t.Logf("waiting for relay cleanup: %s", timeout)
time.Sleep(timeout)
if len(mgr.relayClients) != 0 {
t.Errorf("expected 0, got %d", len(mgr.relayClients))
if mgr.getClientLen() != 0 {
t.Errorf("expected 0, got %d", mgr.getClientLen())
}
t.Logf("closing manager")