forked from External/ergo
Actually let the takeover work somewhat more properly
This commit is contained in:
parent
0d5327de8a
commit
7760634efe
1 changed files with 20 additions and 7 deletions
|
|
@ -351,6 +351,9 @@ func (client *Client) TryResume() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unmark the new client's nick as being occupied
|
||||||
|
server.clients.removeInternal(client)
|
||||||
|
|
||||||
// send RESUMED to the reconnecting client
|
// send RESUMED to the reconnecting client
|
||||||
if timestamp == nil {
|
if timestamp == nil {
|
||||||
client.Send(nil, oldClient.NickMaskString(), "RESUMED", oldClient.nick, client.username, client.Hostname())
|
client.Send(nil, oldClient.NickMaskString(), "RESUMED", oldClient.nick, client.username, client.Hostname())
|
||||||
|
|
@ -402,7 +405,7 @@ func (client *Client) TryResume() {
|
||||||
|
|
||||||
server.clients.byNick[oldnick] = client
|
server.clients.byNick[oldnick] = client
|
||||||
|
|
||||||
oldClient.destroy(false)
|
oldClient.destroy(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IdleTime returns how long this client's been idle.
|
// IdleTime returns how long this client's been idle.
|
||||||
|
|
@ -602,12 +605,14 @@ func (client *Client) Quit(message string) {
|
||||||
// destroy gets rid of a client, removes them from server lists etc.
|
// destroy gets rid of a client, removes them from server lists etc.
|
||||||
func (client *Client) destroy(beingResumed bool) {
|
func (client *Client) destroy(beingResumed bool) {
|
||||||
// allow destroy() to execute at most once
|
// allow destroy() to execute at most once
|
||||||
client.stateMutex.Lock()
|
if !beingResumed {
|
||||||
isDestroyed := client.isDestroyed
|
client.stateMutex.Lock()
|
||||||
client.isDestroyed = true
|
isDestroyed := client.isDestroyed
|
||||||
client.stateMutex.Unlock()
|
client.isDestroyed = true
|
||||||
if isDestroyed {
|
client.stateMutex.Unlock()
|
||||||
return
|
if isDestroyed {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if beingResumed {
|
if beingResumed {
|
||||||
|
|
@ -647,18 +652,26 @@ func (client *Client) destroy(beingResumed bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("2")
|
||||||
|
|
||||||
// clean up server
|
// clean up server
|
||||||
if !beingResumed {
|
if !beingResumed {
|
||||||
client.server.clients.Remove(client)
|
client.server.clients.Remove(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("3")
|
||||||
|
|
||||||
// clean up self
|
// clean up self
|
||||||
if client.idletimer != nil {
|
if client.idletimer != nil {
|
||||||
client.idletimer.Stop()
|
client.idletimer.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("4")
|
||||||
|
|
||||||
client.socket.Close()
|
client.socket.Close()
|
||||||
|
|
||||||
|
fmt.Println("5")
|
||||||
|
|
||||||
// send quit messages to friends
|
// send quit messages to friends
|
||||||
if !beingResumed {
|
if !beingResumed {
|
||||||
for friend := range friends {
|
for friend := range friends {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue