Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Nov 24, 2023
1 parent aec550f commit cc95ebe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sync3/connmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sync3/connmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit cc95ebe

Please sign in to comment.