"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: fix deadlock in mount tests
Nick Craig-Wooda2336ad774d8
diff --git a/vfs/file.go b/vfs/file.goindex 63513d44d..967adae60 100644--- a/vfs/file.go+++ b/vfs/file.go@@ -23,6 +23,7 @@ type File struct {leaf string // leaf name of the objectrwOpenCount int // number of open files on this handlewriters []Handle // writers for this file+ nwriters int32 // len(writers) which is read/updated with atomicreadWriters int // how many RWFileHandle are open for writingreadWriterClosing bool // is a RWFileHandle currently cosing?modified bool // has the cache file be modified by a RWFileHandle?@@ -103,6 +104,7 @@ func (f *File) rename(d *Dir, o fs.Object) {func (f *File) addWriter(h Handle) {f.mu.Lock()f.writers = append(f.writers, h)+ atomic.AddInt32(&f.nwriters, 1)if _, ok := h.(*RWFileHandle); ok {f.readWriters++}@@ -122,6 +124,7 @@ func (f *File) delWriter(h Handle, modifiedCacheFile bool) (lastWriterAndModifie}if found >= 0 {f.writers = append(f.writers[:found], f.writers[found+1:]...)+ atomic.AddInt32(&f.nwriters, -1)} else {fs.Debugf(f.o, "File.delWriter couldn't find handle")}@@ -172,10 +175,11 @@ func (f *File) finishWriterClose() {}// activeWriters returns the number of writers on the file+//+// Note that we don't take the mutex here. If we do then we can get a+// deadlock.func (f *File) activeWriters() int {- f.mu.Lock()- defer f.mu.Unlock()- return len(f.writers)+ return int(atomic.LoadInt32(&f.nwriters))}// ModTime returns the modified time of the file