3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

preregNick doesn't need synchronization

(since it's only accessed from the client's own goroutine)
This commit is contained in:
Shivaram Lingamneni 2019-01-01 23:45:47 -05:00
parent f94f737b31
commit 9a2117f75d
3 changed files with 4 additions and 17 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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
}