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()
|
client.clearMonitorList()
|
||||||
|
|
||||||
// clean up channels
|
// clean up channels
|
||||||
|
client.server.channelJoinPartMutex.Lock()
|
||||||
for channel := range client.channels {
|
for channel := range client.channels {
|
||||||
channel.Quit(client, &friends)
|
channel.Quit(client, &friends)
|
||||||
}
|
}
|
||||||
|
client.server.channelJoinPartMutex.Unlock()
|
||||||
|
|
||||||
// clean up server
|
// clean up server
|
||||||
client.server.clients.Remove(client)
|
client.server.clients.Remove(client)
|
||||||
|
@ -86,6 +86,7 @@ type Server struct {
|
|||||||
accounts map[string]*ClientAccount
|
accounts map[string]*ClientAccount
|
||||||
channelRegistrationEnabled bool
|
channelRegistrationEnabled bool
|
||||||
channels ChannelNameMap
|
channels ChannelNameMap
|
||||||
|
channelJoinPartMutex sync.Mutex // used when joining/parting channels to prevent stomping over each others' access and all
|
||||||
checkIdent bool
|
checkIdent bool
|
||||||
clients *ClientLookupSet
|
clients *ClientLookupSet
|
||||||
commands chan Command
|
commands chan Command
|
||||||
@ -802,6 +803,10 @@ func joinHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
keys = strings.Split(msg.Params[1], ",")
|
keys = strings.Split(msg.Params[1], ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get lock
|
||||||
|
server.channelJoinPartMutex.Lock()
|
||||||
|
defer server.channelJoinPartMutex.Unlock()
|
||||||
|
|
||||||
for i, name := range channels {
|
for i, name := range channels {
|
||||||
casefoldedName, err := CasefoldChannel(name)
|
casefoldedName, err := CasefoldChannel(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -838,6 +843,10 @@ func partHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
reason = msg.Params[1]
|
reason = msg.Params[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get lock
|
||||||
|
server.channelJoinPartMutex.Lock()
|
||||||
|
defer server.channelJoinPartMutex.Unlock()
|
||||||
|
|
||||||
for _, chname := range channels {
|
for _, chname := range channels {
|
||||||
casefoldedChannelName, err := CasefoldChannel(chname)
|
casefoldedChannelName, err := CasefoldChannel(chname)
|
||||||
channel := server.channels.Get(casefoldedChannelName)
|
channel := server.channels.Get(casefoldedChannelName)
|
||||||
|
Loading…
Reference in New Issue
Block a user