mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
preregNick doesn't need synchronization
(since it's only accessed from the client's own goroutine)
This commit is contained in:
parent
f94f737b31
commit
9a2117f75d
@ -179,18 +179,6 @@ func (client *Client) SetAuthorized(authorized bool) {
|
||||
client.authorized = authorized
|
||||
}
|
||||
|
||||
func (client *Client) PreregNick() string {
|
||||
client.stateMutex.RLock()
|
||||
defer client.stateMutex.RUnlock()
|
||||
return client.preregNick
|
||||
}
|
||||
|
||||
func (client *Client) SetPreregNick(preregNick string) {
|
||||
client.stateMutex.Lock()
|
||||
defer client.stateMutex.Unlock()
|
||||
client.preregNick = preregNick
|
||||
}
|
||||
|
||||
func (client *Client) HasMode(mode modes.Mode) bool {
|
||||
// client.flags has its own synch
|
||||
return client.flags.HasMode(mode)
|
||||
|
@ -1662,7 +1662,7 @@ func nickHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
||||
if client.Registered() {
|
||||
performNickChange(server, client, client, msg.Params[0], rb)
|
||||
} else {
|
||||
client.SetPreregNick(msg.Params[0])
|
||||
client.preregNick = msg.Params[0]
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -386,8 +386,7 @@ func (server *Server) tryRegister(c *Client) {
|
||||
return
|
||||
}
|
||||
|
||||
preregNick := c.PreregNick()
|
||||
if preregNick == "" || !c.HasUsername() || c.capState == caps.NegotiatingState {
|
||||
if c.preregNick == "" || !c.HasUsername() || c.capState == caps.NegotiatingState {
|
||||
return
|
||||
}
|
||||
|
||||
@ -400,10 +399,10 @@ func (server *Server) tryRegister(c *Client) {
|
||||
}
|
||||
|
||||
rb := NewResponseBuffer(c)
|
||||
nickAssigned := performNickChange(server, c, c, preregNick, rb)
|
||||
nickAssigned := performNickChange(server, c, c, c.preregNick, rb)
|
||||
rb.Send(true)
|
||||
if !nickAssigned {
|
||||
c.SetPreregNick("")
|
||||
c.preregNick = ""
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user