Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
fix:RLock twice when broadcast.Rooms(nil) (#562)
Browse files Browse the repository at this point in the history
* fix:RLock twice when broadcast.Rooms(nil)
---------

Co-authored-by: zengzz01 <zengzz01@mingyuanyun.com>
  • Loading branch information
zengzhuozhen and zengzz01 authored Jan 30, 2023
1 parent 9b8a2e8 commit 1a06b55
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ func (bc *broadcast) Len(room string) int {
// no connection is given, in case of a connection is given, it gives
// list of all the rooms the connection is joined to
func (bc *broadcast) Rooms(connection Conn) []string {
bc.lock.RLock()
defer bc.lock.RUnlock()

if connection == nil {
return bc.AllRooms()
}

bc.lock.RLock()
defer bc.lock.RUnlock()

return bc.getRoomsByConn(connection)
}

Expand Down

0 comments on commit 1a06b55

Please sign in to comment.