mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:09:55 +08:00
cmount: don't attempt to unmount if fs has been destroyed already #4957
This commit is contained in:
parent
41127965b0
commit
2f67681e3b
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/billziss-gh/cgofuse/fuse"
|
"github.com/billziss-gh/cgofuse/fuse"
|
||||||
|
@ -23,11 +24,12 @@ const fhUnset = ^uint64(0)
|
||||||
|
|
||||||
// FS represents the top level filing system
|
// FS represents the top level filing system
|
||||||
type FS struct {
|
type FS struct {
|
||||||
VFS *vfs.VFS
|
VFS *vfs.VFS
|
||||||
f fs.Fs
|
f fs.Fs
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFS makes a new FS
|
// NewFS makes a new FS
|
||||||
|
@ -187,6 +189,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getattr reads the attributes for path
|
// Getattr reads the attributes for path
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/billziss-gh/cgofuse/fuse"
|
"github.com/billziss-gh/cgofuse/fuse"
|
||||||
|
@ -168,7 +169,10 @@ 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 atexit.Signalled() {
|
if atomic.LoadInt32(&fsys.destroyed) != 0 {
|
||||||
|
fs.Debugf(nil, "Not calling host.Unmount as mount already Destroyed")
|
||||||
|
umountOK = true
|
||||||
|
} else if atexit.Signalled() {
|
||||||
// If we have received a signal then FUSE will be shutting down already
|
// If we have received a signal then FUSE will be shutting down already
|
||||||
fs.Debugf(nil, "Not calling host.Unmount as signal received")
|
fs.Debugf(nil, "Not calling host.Unmount as signal received")
|
||||||
umountOK = true
|
umountOK = true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user