diff options
author | Tulir Asokan <tulir@maunium.net> | 2019-04-27 15:11:38 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2019-04-27 15:11:38 +0300 |
commit | 08d99d776d359aa1ef056e4455f82d92b6940507 (patch) | |
tree | 81039836f203a57eaa53e008039d9562d2bbb576 | |
parent | b6b50e8e1df54e8ad0a4b5449333ec5e987966ce (diff) |
Fix potential deadlock in room switching
-rw-r--r-- | ui/room-list.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ui/room-list.go b/ui/room-list.go index 0dc3e74..6b22c8e 100644 --- a/ui/room-list.go +++ b/ui/room-list.go @@ -438,11 +438,11 @@ func (list *RoomList) clickRoom(line, column int, mod bool) bool { return false } list.RLock() - defer list.RUnlock() for _, tag := range list.tags { trl := list.items[tag] if line--; line == -1 { trl.ToggleCollapse() + list.RUnlock() return true } @@ -453,7 +453,9 @@ func (list *RoomList) clickRoom(line, column int, mod bool) bool { if line < 0 { break } else if line < trl.Length() { - list.parent.SwitchRoom(tag, trl.Visible()[trl.Length()-1-line].Room) + switchToRoom := trl.Visible()[trl.Length()-1-line].Room + list.RUnlock() + list.parent.SwitchRoom(tag, switchToRoom) return true } @@ -482,6 +484,7 @@ func (list *RoomList) clickRoom(line, column int, mod bool) bool { // Tag footer line-- } + list.RUnlock() return false } |