3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

Merge pull request #815 from slingamn/issue814_lusers_registration

fix #814
This commit is contained in:
Shivaram Lingamneni 2020-02-25 11:24:56 -08:00 committed by GitHub
commit 5a300a9070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -1181,7 +1181,8 @@ func (client *Client) destroy(session *Session) {
// should we destroy the whole client this time?
// BRB is not respected if this is a destroy of the whole client (i.e., session == nil)
brbEligible := session != nil && (brbState == BrbEnabled || alwaysOn)
shouldDestroy := !client.destroyed && remainingSessions == 0 && !brbEligible
alreadyDestroyed := client.destroyed
shouldDestroy := !alreadyDestroyed && remainingSessions == 0 && !brbEligible
if shouldDestroy {
// if it's our job to destroy it, don't let anyone else try
client.destroyed = true
@ -1230,7 +1231,7 @@ func (client *Client) destroy(session *Session) {
}
// decrement stats if we have no more sessions, even if the client will not be destroyed
if shouldDestroy || remainingSessions == 0 {
if shouldDestroy || (!alreadyDestroyed && remainingSessions == 0) {
invisible := client.HasMode(modes.Invisible)
operator := client.HasMode(modes.LocalOperator) || client.HasMode(modes.Operator)
client.server.stats.Remove(registered, invisible, operator)

View File

@ -54,22 +54,18 @@ func (cmd *Command) Run(server *Server, client *Client, session *Session, msg ir
return cmd.handler(server, client, msg, rb)
}()
// after each command, see if we can send registration to the client
if !exiting && !client.registered {
exiting = server.tryRegister(client, session)
}
// most servers do this only for PING/PONG, but we'll do it for any command:
if client.registered {
// touch even if `exiting`, so we record the time of a QUIT accurately
session.idletimer.Touch()
}
if exiting {
return
}
// after each command, see if we can send registration to the client
if !client.registered {
exiting = server.tryRegister(client, session)
}
if client.registered && !cmd.leaveClientIdle {
if !exiting && client.registered && !cmd.leaveClientIdle {
client.Active(session)
}