mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +01:00
channels: Help prevent issues when join/parting
This commit is contained in:
parent
4a66771c39
commit
f665ebac16
@ -483,9 +483,11 @@ func (client *Client) destroy() {
|
||||
client.clearMonitorList()
|
||||
|
||||
// clean up channels
|
||||
client.server.channelJoinPartMutex.Lock()
|
||||
for channel := range client.channels {
|
||||
channel.Quit(client, &friends)
|
||||
}
|
||||
client.server.channelJoinPartMutex.Unlock()
|
||||
|
||||
// clean up server
|
||||
client.server.clients.Remove(client)
|
||||
|
@ -86,6 +86,7 @@ type Server struct {
|
||||
accounts map[string]*ClientAccount
|
||||
channelRegistrationEnabled bool
|
||||
channels ChannelNameMap
|
||||
channelJoinPartMutex sync.Mutex // used when joining/parting channels to prevent stomping over each others' access and all
|
||||
checkIdent bool
|
||||
clients *ClientLookupSet
|
||||
commands chan Command
|
||||
@ -802,6 +803,10 @@ func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
keys = strings.Split(msg.Params[1], ",")
|
||||
}
|
||||
|
||||
// get lock
|
||||
server.channelJoinPartMutex.Lock()
|
||||
defer server.channelJoinPartMutex.Unlock()
|
||||
|
||||
for i, name := range channels {
|
||||
casefoldedName, err := CasefoldChannel(name)
|
||||
if err != nil {
|
||||
@ -838,6 +843,10 @@ func partHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
reason = msg.Params[1]
|
||||
}
|
||||
|
||||
// get lock
|
||||
server.channelJoinPartMutex.Lock()
|
||||
defer server.channelJoinPartMutex.Unlock()
|
||||
|
||||
for _, chname := range channels {
|
||||
casefoldedChannelName, err := CasefoldChannel(chname)
|
||||
channel := server.channels.Get(casefoldedChannelName)
|
||||
|
Loading…
Reference in New Issue
Block a user