3
0
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:
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 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 { func (client *Client) HasMode(mode modes.Mode) bool {
// client.flags has its own synch // client.flags has its own synch
return client.flags.HasMode(mode) 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() { if client.Registered() {
performNickChange(server, client, client, msg.Params[0], rb) performNickChange(server, client, client, msg.Params[0], rb)
} else { } else {
client.SetPreregNick(msg.Params[0]) client.preregNick = msg.Params[0]
} }
return false return false
} }

View File

@ -386,8 +386,7 @@ func (server *Server) tryRegister(c *Client) {
return return
} }
preregNick := c.PreregNick() if c.preregNick == "" || !c.HasUsername() || c.capState == caps.NegotiatingState {
if preregNick == "" || !c.HasUsername() || c.capState == caps.NegotiatingState {
return return
} }
@ -400,10 +399,10 @@ func (server *Server) tryRegister(c *Client) {
} }
rb := NewResponseBuffer(c) rb := NewResponseBuffer(c)
nickAssigned := performNickChange(server, c, c, preregNick, rb) nickAssigned := performNickChange(server, c, c, c.preregNick, rb)
rb.Send(true) rb.Send(true)
if !nickAssigned { if !nickAssigned {
c.SetPreregNick("") c.preregNick = ""
return return
} }