SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix leaking goroutines (#7291)
Chris Lu0b51133fd30e
diff --git a/weed/mount/weedfs_file_lseek.go b/weed/mount/weedfs_file_lseek.goindex 73564fdbe6..a7e3a2b46c 100644--- a/weed/mount/weedfs_file_lseek.go+++ b/weed/mount/weedfs_file_lseek.go@@ -58,10 +58,14 @@ func (wfs *WFS) Lseek(cancel <-chan struct{}, in *fuse.LseekIn, out *fuse.LseekO// Create a context that will be cancelled when the cancel channel receives a signalctx, cancelFunc := context.WithCancel(context.Background())+ defer cancelFunc() // Ensure cleanup+go func() {select {case <-cancel:cancelFunc()+ case <-ctx.Done():+ // Clean exit when lseek operation completes}}()diff --git a/weed/mount/weedfs_file_read.go b/weed/mount/weedfs_file_read.goindex 5a5a5efabf..c85478cd08 100644--- a/weed/mount/weedfs_file_read.go+++ b/weed/mount/weedfs_file_read.go@@ -49,14 +49,13 @@ func (wfs *WFS) Read(cancel <-chan struct{}, in *fuse.ReadIn, buff []byte) (fuse// Create a context that will be cancelled when the cancel channel receives a signalctx, cancelFunc := context.WithCancel(context.Background())- defer cancelFunc()-+ defer cancelFunc() // Ensure cleanup+go func() {select {case <-cancel:cancelFunc()case <-ctx.Done():- // Context already cancelled, exit goroutine}}()