cmount: use atomic types

This commit is contained in:
Roberto Ricci 2023-08-18 16:44:23 +02:00 committed by Nick Craig-Wood
parent 123a030441
commit 50d0597d56
2 changed files with 3 additions and 4 deletions

View File

@ -30,7 +30,7 @@ type FS struct {
ready chan (struct{}) ready chan (struct{})
mu sync.Mutex // to protect the below mu sync.Mutex // to protect the below
handles []vfs.Handle handles []vfs.Handle
destroyed int32 // read/write with sync/atomic destroyed atomic.Int32
} }
// NewFS makes a new FS // NewFS makes a new FS
@ -190,7 +190,7 @@ func (fsys *FS) Init() {
// Destroy call). // Destroy call).
func (fsys *FS) Destroy() { func (fsys *FS) Destroy() {
defer log.Trace(fsys.f, "")("") defer log.Trace(fsys.f, "")("")
atomic.StoreInt32(&fsys.destroyed, 1) fsys.destroyed.Store(1)
} }
// Getattr reads the attributes for path // Getattr reads the attributes for path

View File

@ -13,7 +13,6 @@ import (
"os" "os"
"runtime" "runtime"
"strings" "strings"
"sync/atomic"
"time" "time"
"github.com/rclone/rclone/cmd/mountlib" "github.com/rclone/rclone/cmd/mountlib"
@ -192,7 +191,7 @@ func mount(VFS *vfs.VFS, mountPath string, opt *mountlib.Options) (<-chan error,
// Shutdown the VFS // Shutdown the VFS
fsys.VFS.Shutdown() fsys.VFS.Shutdown()
var umountOK bool var umountOK bool
if atomic.LoadInt32(&fsys.destroyed) != 0 { if fsys.destroyed.Load() != 0 {
fs.Debugf(nil, "Not calling host.Unmount as mount already Destroyed") fs.Debugf(nil, "Not calling host.Unmount as mount already Destroyed")
umountOK = true umountOK = true
} else if atexit.Signalled() { } else if atexit.Signalled() {