mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
synchronize accesses to client.atime
This commit is contained in:
parent
ad351268be
commit
f5e7ec525d
@ -261,6 +261,8 @@ func (client *Client) run() {
|
||||
|
||||
// Active updates when the client was last 'active' (i.e. the user should be sitting in front of their client).
|
||||
func (client *Client) Active() {
|
||||
client.stateMutex.Lock()
|
||||
defer client.stateMutex.Unlock()
|
||||
client.atime = time.Now()
|
||||
}
|
||||
|
||||
@ -298,6 +300,8 @@ func (client *Client) Register() {
|
||||
|
||||
// IdleTime returns how long this client's been idle.
|
||||
func (client *Client) IdleTime() time.Duration {
|
||||
client.stateMutex.RLock()
|
||||
defer client.stateMutex.RUnlock()
|
||||
return time.Since(client.atime)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user