diff options
author | Jakob Unterwurzacher | 2019-09-08 16:29:20 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-09-08 16:29:20 +0200 |
commit | 0a4db7d9e9801a416602b52281537991ba1463c0 (patch) | |
tree | 396f3786cd0186e1c0f592512fc4adac5fed0b5a /mount.go | |
parent | ce13851bbfceb02da0b36e743090c5fe54469b33 (diff) |
Fix -idle unmounting despite activity
Fixes https://github.com/rfjakob/gocryptfs/issues/421
Diffstat (limited to 'mount.go')
-rw-r--r-- | mount.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -181,18 +181,18 @@ func idleMonitor(idleTimeout time.Duration, fs *fusefrontend.FS, srv *fuse.Serve timeoutCycles := int(math.Ceil(float64(idleTimeout) / float64(sleepTimeBetweenChecks))) idleCount := 0 for { - // Atomically check whether the access flag is set and reset it to 0 if so. - recentAccess := atomic.CompareAndSwapUint32(&fs.AccessedSinceLastCheck, 1, 0) + // Atomically check whether the flag is 0 and reset it to 1 if so. + isIdle := !atomic.CompareAndSwapUint32(&fs.IsIdle, 0, 1) // Any form of current or recent access resets the idle counter. openFileCount := openfiletable.CountOpenFiles() - if recentAccess || openFileCount > 0 { + if !isIdle || openFileCount > 0 { idleCount = 0 } else { idleCount++ } tlog.Debug.Printf( - "Checking for idle (recentAccess = %t, open = %d): %s", - recentAccess, openFileCount, time.Now().String()) + "Checking for idle (isIdle = %t, open = %d): %s", + isIdle, openFileCount, time.Now().String()) if idleCount > 0 && idleCount%timeoutCycles == 0 { tlog.Info.Printf("Filesystem idle; unmounting: %s", mountpoint) unmount(srv, mountpoint) |