forked from External/ergo
do idle in the server goroutine instead of the timeout goroutine
This commit is contained in:
parent
4f106e7d3e
commit
2bc1b952a0
2 changed files with 11 additions and 13 deletions
|
|
@ -79,26 +79,24 @@ func (client *Client) Touch() {
|
|||
}
|
||||
|
||||
if client.idleTimer == nil {
|
||||
client.idleTimer = time.AfterFunc(IDLE_TIMEOUT, client.Idle)
|
||||
client.idleTimer = time.AfterFunc(IDLE_TIMEOUT, client.connectionIdle)
|
||||
} else {
|
||||
client.idleTimer.Reset(IDLE_TIMEOUT)
|
||||
}
|
||||
}
|
||||
|
||||
type ClientIdle struct {
|
||||
BaseCommand
|
||||
}
|
||||
|
||||
func (client *Client) Idle() {
|
||||
client.Reply(RplPing(client.server, client))
|
||||
|
||||
if client.quitTimer == nil {
|
||||
client.quitTimer = time.AfterFunc(QUIT_TIMEOUT, client.connectionTimeout)
|
||||
} else {
|
||||
client.quitTimer.Reset(QUIT_TIMEOUT)
|
||||
}
|
||||
}
|
||||
|
||||
cmd := &ClientIdle{}
|
||||
cmd.SetClient(client)
|
||||
client.server.commands <- cmd
|
||||
func (client *Client) connectionIdle() {
|
||||
client.server.idle <- client
|
||||
}
|
||||
|
||||
func (client *Client) connectionTimeout() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue