mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 15:30:06 +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"
|
||||
"path"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/billziss-gh/cgofuse/fuse"
|
||||
|
@ -23,11 +24,12 @@ const fhUnset = ^uint64(0)
|
|||
|
||||
// FS represents the top level filing system
|
||||
type FS struct {
|
||||
VFS *vfs.VFS
|
||||
f fs.Fs
|
||||
ready chan (struct{})
|
||||
mu sync.Mutex // to protect the below
|
||||
handles []vfs.Handle
|
||||
VFS *vfs.VFS
|
||||
f fs.Fs
|
||||
ready chan (struct{})
|
||||
mu sync.Mutex // to protect the below
|
||||
handles []vfs.Handle
|
||||
destroyed int32 // read/write with sync/atomic
|
||||
}
|
||||
|
||||
// NewFS makes a new FS
|
||||
|
@ -187,6 +189,7 @@ func (fsys *FS) Init() {
|
|||
// Destroy call).
|
||||
func (fsys *FS) Destroy() {
|
||||
defer log.Trace(fsys.f, "")("")
|
||||
atomic.StoreInt32(&fsys.destroyed, 1)
|
||||
}
|
||||
|
||||
// Getattr reads the attributes for path
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"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
|
||||
fsys.VFS.Shutdown()
|
||||
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
|
||||
fs.Debugf(nil, "Not calling host.Unmount as signal received")
|
||||
umountOK = true
|
||||
|
|
Loading…
Reference in New Issue
Block a user