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

qingstor: fix go routine leak on multipart upload errors - fixes #2851

Nick Craig-Wood9685be64cd41
diff --git a/backend/qingstor/upload.go b/backend/qingstor/upload.go
index a27b61643..43f635c90 100644
--- a/backend/qingstor/upload.go
+++ b/backend/qingstor/upload.go
@@ -392,6 +392,14 @@ func (mu *multiUploader) multiPartUpload(firstBuf io.ReadSeeker) error {
var nextChunkLen int
reader, nextChunkLen, err = mu.nextReader()
if err != nil && err != io.EOF {
+ // empty ch
+ go func() {
+ for range ch {
+ }
+ }()
+ // Wait for all goroutines finish
+ close(ch)
+ mu.wg.Wait()
return err
}
if nextChunkLen == 0 && partNumber > 0 {