Merge pull request #1227 from slingamn/issue1225.2

fix #1225
This commit is contained in:
Shivaram Lingamneni 2020-08-06 01:19:39 -07:00 committed by GitHub
commit 55b21fa86c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 24 deletions

View file

@ -235,20 +235,15 @@ func (client *Client) Oper() *Oper {
return client.oper
}
func (client *Client) Registered() bool {
client.stateMutex.RLock()
defer client.stateMutex.RUnlock()
return client.registered
}
func (client *Client) SetRegistered() {
func (client *Client) Registered() (result bool) {
// `registered` is only written from the client's own goroutine, but may be
// read from other goroutines; therefore, the client's own goroutine may read
// the value without synchronization, but must write it with synchronization,
// and other goroutines must read it with synchronization
client.stateMutex.Lock()
client.registered = true
client.stateMutex.Unlock()
client.stateMutex.RLock()
result = client.registered
client.stateMutex.RUnlock()
return
}
func (client *Client) RawHostname() (result string) {