aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2025-05-29 21:30:53 +0200
committerJakob Unterwurzacher2025-05-29 21:38:25 +0200
commit2609c72beee098c6afe4bbc3344a1fcee06df94b (patch)
tree3cc6f67dd36e57709da150370c3ebb71ce11f3e3
parent735b194a2c6e6c2c36ecfb37b0e64d16e52577bf (diff)
idleMonitor: switch to the new atomic.Bool api
-rw-r--r--internal/fusefrontend/node_prepare_syscall.go3
-rw-r--r--internal/fusefrontend/root_node.go2
-rw-r--r--mount.go3
3 files changed, 3 insertions, 5 deletions
diff --git a/internal/fusefrontend/node_prepare_syscall.go b/internal/fusefrontend/node_prepare_syscall.go
index 2a4d6ab..9021350 100644
--- a/internal/fusefrontend/node_prepare_syscall.go
+++ b/internal/fusefrontend/node_prepare_syscall.go
@@ -1,7 +1,6 @@
package fusefrontend
import (
- "sync/atomic"
"syscall"
"github.com/rfjakob/gocryptfs/v2/internal/tlog"
@@ -24,7 +23,7 @@ func (n *Node) prepareAtSyscall(child string) (dirfd int, cName string, errno sy
// All filesystem operations go through here, so this is a good place
// to reset the idle marker.
- atomic.StoreUint32(&rn.IsIdle, 0)
+ rn.IsIdle.Store(false)
if n.IsRoot() && rn.isFiltered(child) {
return -1, "", syscall.EPERM
diff --git a/internal/fusefrontend/root_node.go b/internal/fusefrontend/root_node.go
index d2950a1..8464c5f 100644
--- a/internal/fusefrontend/root_node.go
+++ b/internal/fusefrontend/root_node.go
@@ -45,7 +45,7 @@ type RootNode struct {
// (uint32 so that it can be reset with CompareAndSwapUint32).
// When -idle was used when mounting, idleMonitor() sets it to 1
// periodically.
- IsIdle uint32
+ IsIdle atomic.Bool
// dirCache caches directory fds
dirCache dirCache
// inoMap translates inode numbers from different devices to unique inode
diff --git a/mount.go b/mount.go
index fe82c0c..1005a39 100644
--- a/mount.go
+++ b/mount.go
@@ -13,7 +13,6 @@ import (
"runtime"
"runtime/debug"
"strings"
- "sync/atomic"
"syscall"
"time"
@@ -181,7 +180,7 @@ func idleMonitor(idleTimeout time.Duration, fs *fusefrontend.RootNode, srv *fuse
}
for {
// Atomically check whether the flag is 0 and reset it to 1 if so.
- isIdle := !atomic.CompareAndSwapUint32(&fs.IsIdle, 0, 1)
+ isIdle := !fs.IsIdle.CompareAndSwap(false, true)
// Any form of current or recent access resets the idle counter.
openFileCount := openfiletable.CountOpenFiles()
if !isIdle || openFileCount > 0 {