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

View File

@ -13,7 +13,6 @@ import (
"os"
"runtime"
"strings"
"sync/atomic"
"time"
"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
fsys.VFS.Shutdown()
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")
umountOK = true
} else if atexit.Signalled() {