mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Actually let the takeover work somewhat more properly
This commit is contained in:
parent
0d5327de8a
commit
7760634efe
@ -351,6 +351,9 @@ func (client *Client) TryResume() {
|
||||
return
|
||||
}
|
||||
|
||||
// unmark the new client's nick as being occupied
|
||||
server.clients.removeInternal(client)
|
||||
|
||||
// send RESUMED to the reconnecting client
|
||||
if timestamp == nil {
|
||||
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
|
||||
|
||||
oldClient.destroy(false)
|
||||
oldClient.destroy(true)
|
||||
}
|
||||
|
||||
// IdleTime returns how long this client's been idle.
|
||||
@ -602,6 +605,7 @@ func (client *Client) Quit(message string) {
|
||||
// destroy gets rid of a client, removes them from server lists etc.
|
||||
func (client *Client) destroy(beingResumed bool) {
|
||||
// allow destroy() to execute at most once
|
||||
if !beingResumed {
|
||||
client.stateMutex.Lock()
|
||||
isDestroyed := client.isDestroyed
|
||||
client.isDestroyed = true
|
||||
@ -609,6 +613,7 @@ func (client *Client) destroy(beingResumed bool) {
|
||||
if isDestroyed {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if beingResumed {
|
||||
client.server.logger.Debug("quit", fmt.Sprintf("%s is being resumed", client.nick))
|
||||
@ -647,18 +652,26 @@ func (client *Client) destroy(beingResumed bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("2")
|
||||
|
||||
// clean up server
|
||||
if !beingResumed {
|
||||
client.server.clients.Remove(client)
|
||||
}
|
||||
|
||||
fmt.Println("3")
|
||||
|
||||
// clean up self
|
||||
if client.idletimer != nil {
|
||||
client.idletimer.Stop()
|
||||
}
|
||||
|
||||
fmt.Println("4")
|
||||
|
||||
client.socket.Close()
|
||||
|
||||
fmt.Println("5")
|
||||
|
||||
// send quit messages to friends
|
||||
if !beingResumed {
|
||||
for friend := range friends {
|
||||
|
Loading…
Reference in New Issue
Block a user