Review comments

This commit is contained in:
Kegan Dougal 2023-11-24 15:23:35 +00:00
parent aec550f9b4
commit cc95ebe1e4
2 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"golang.org/x/exp/slices"
"github.com/ReneKroon/ttlcache/v2"
"github.com/matrix-org/sliding-sync/internal"
"github.com/prometheus/client_golang/prometheus"
)
@ -169,6 +170,7 @@ func (m *ConnMap) CloseConnsForDevice(userID, deviceID string) {
err := m.cache.Remove(cid.String()) // this will fire TTL callbacks which calls closeConn
if err != nil {
logger.Err(err).Str("cid", cid.String()).Msg("CloseConnsForDevice: cid did not exist in ttlcache")
internal.GetSentryHubFromContextOrDefault(context.Background()).CaptureException(err)
}
}
}
@ -199,6 +201,7 @@ func (m *ConnMap) CloseConnsForUsers(userIDs []string) (closed int) {
err := m.cache.Remove(conn.String()) // this will fire TTL callbacks which calls closeConn
if err != nil {
logger.Err(err).Str("cid", conn.String()).Msg("CloseConnsForDevice: cid did not exist in ttlcache")
internal.GetSentryHubFromContextOrDefault(context.Background()).CaptureException(err)
}
}
closed += len(conns)

View File

@ -87,7 +87,7 @@ func TestConnMap_CloseConnsForUser(t *testing.T) {
time.Sleep(100 * time.Millisecond) // some stuff happens asyncly in goroutines
must.Equal(t, num, 6, "unexpected number of closed conns")
// Destroy should have been called for all alice|A connections
// Destroy should have been called for all alice connections
assertDestroyedConns(t, cidToConn, func(cid ConnID) bool {
return cid.UserID == alice
})