"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
smb: use atomic types
Roberto Ricci123a030441ca
diff --git a/backend/smb/connpool.go b/backend/smb/connpool.goindex ee3b0c208..5b8caef03 100644--- a/backend/smb/connpool.go+++ b/backend/smb/connpool.go@@ -4,7 +4,6 @@ import ("context""fmt""net"- "sync/atomic""time"smb2 "github.com/hirochachacha/go-smb2"@@ -89,17 +88,17 @@ func (c *conn) closed() bool {//// Call removeSession() when donefunc (f *Fs) addSession() {- atomic.AddInt32(&f.sessions, 1)+ f.sessions.Add(1)}// Show the SMB session is no longer in usefunc (f *Fs) removeSession() {- atomic.AddInt32(&f.sessions, -1)+ f.sessions.Add(-1)}// getSessions shows whether there are any sessions in usefunc (f *Fs) getSessions() int32 {- return atomic.LoadInt32(&f.sessions)+ return f.sessions.Load()}// Open a new connection to the SMB server.diff --git a/backend/smb/smb.go b/backend/smb/smb.goindex b9ad5353b..704c998f9 100644--- a/backend/smb/smb.go+++ b/backend/smb/smb.go@@ -9,6 +9,7 @@ import ("path""strings""sync"+ "sync/atomic""time""github.com/rclone/rclone/fs"@@ -140,7 +141,7 @@ type Fs struct {features *fs.Features // optional featurespacer *fs.Pacer // pacer for operations- sessions int32+ sessions atomic.Int32poolMu sync.Mutexpool []*conndrain *time.Timer // used to drain the pool when we stop using the connections