Skip to content

Commit

Permalink
Rename closeStaleConnections to compareAndCloseStaleConnections
Browse files Browse the repository at this point in the history
  • Loading branch information
aruiz14 committed Jun 17, 2024
1 parent ee938dc commit 14c3d27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion session_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (s *Session) syncConnections(r io.Reader) error {
return fmt.Errorf("decoding sync connections payload: %w", err)
}

s.closeStaleConnections(clientActiveConnections)
s.compareAndCloseStaleConnections(clientActiveConnections)
return nil
}

Expand Down
5 changes: 2 additions & 3 deletions session_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ func (s *Session) sendSyncConnections() error {
return err
}

// closeMissingConnections closes any session connection that is not present in the IDs received from the client
// The session lock must be hold by the caller when calling this method
func (s *Session) closeStaleConnections(clientIDs []int64) {
// compareAndCloseStaleConnections compares the Session's activeConnectionIDs with the provided list from the client, then closing every connection not present in it
func (s *Session) compareAndCloseStaleConnections(clientIDs []int64) {
serverIDs := s.activeConnectionIDs()
toClose := diffSortedSetsGetRemoved(serverIDs, clientIDs)
if len(toClose) == 0 {
Expand Down

0 comments on commit 14c3d27

Please sign in to comment.