Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

oracleobjectstorage, sftp: eliminate unnecessary heap allocation

Qingwei Li530a901de3cf
diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go
index 88ddc1008..5b73801b0 100644
--- a/backend/ftp/ftp.go
+++ b/backend/ftp/ftp.go
@@ -898,7 +898,7 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
resultchan := make(chan []*ftp.Entry, 1)
errchan := make(chan error, 1)
- go func() {
+ go func(c *ftp.ServerConn) {
result, err := c.List(f.dirFromStandardPath(path.Join(f.root, dir)))
f.putFtpConnection(&c, err)
if err != nil {
@@ -906,7 +906,7 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
return
}
resultchan <- result
- }()
+ }(c)
// Wait for List for up to Timeout seconds
timer := time.NewTimer(f.ci.TimeoutOrInfinite())
diff --git a/backend/oracleobjectstorage/waiter.go b/backend/oracleobjectstorage/waiter.go
index d09f00033..ec6dc7463 100644
--- a/backend/oracleobjectstorage/waiter.go
+++ b/backend/oracleobjectstorage/waiter.go
@@ -60,9 +60,6 @@ type StateChangeConf struct {
func (conf *StateChangeConf) WaitForStateContext(ctx context.Context, entityType string) (any, error) {
// fs.Debugf(entityType, "Waiting for state to become: %s", conf.Target)
- notfoundTick := 0
- targetOccurrence := 0
-
// Set a default for times to check for not found
if conf.NotFoundChecks == 0 {
conf.NotFoundChecks = 20
@@ -84,9 +81,11 @@ func (conf *StateChangeConf) WaitForStateContext(ctx context.Context, entityType
// cancellation channel for the refresh loop
cancelCh := make(chan struct{})
- result := Result{}
-
go func() {
+ notfoundTick := 0
+ targetOccurrence := 0
+ result := Result{}
+
defer close(resCh)
select {
diff --git a/cmd/serve/sftp/connection.go b/cmd/serve/sftp/connection.go
index 5d174c2ab..a9282fc5b 100644
--- a/cmd/serve/sftp/connection.go
+++ b/cmd/serve/sftp/connection.go
@@ -291,7 +291,7 @@ func (c *conn) handleChannel(newChannel ssh.NewChannel) {
}
}
fs.Debugf(c.what, " - accepted: %v\n", ok)
- err = req.Reply(ok, reply)
+ err := req.Reply(ok, reply)
if err != nil {
fs.Errorf(c.what, "Failed to Reply to request: %v", err)
return