From 6abb291290538c87bf6843975f2db334f0311355 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 6 May 2024 02:30:00 -0400 Subject: [PATCH] fix deadlock on channel state mutex --- irc/getters.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/irc/getters.go b/irc/getters.go index 18ae58a4..abedb246 100644 --- a/irc/getters.go +++ b/irc/getters.go @@ -612,9 +612,11 @@ func (channel *Channel) Founder() string { func (channel *Channel) HighestUserMode(client *Client) (result modes.Mode) { channel.stateMutex.RLock() - clientModes := channel.members[client].modes - channel.stateMutex.RUnlock() - return clientModes.HighestChannelUserMode() + defer channel.stateMutex.RUnlock() + if clientData, ok := channel.members[client]; ok { + return clientData.modes.HighestChannelUserMode() + } + return } func (channel *Channel) Settings() (result ChannelSettings) {