Browse Source

FUSE Mount: resolve memory leak in Read method goroutine (#7270) (#7282)

* Add defer cancelFunc() to ensure context is always cancelled

* Add ctx.Done() case in goroutine select to prevent goroutine leak

* Fixes memory accumulation issue where goroutines were not properly cleaned up
master
Jaehoon Kim 4 days ago
committed by GitHub
parent
commit
fc89e97af7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      weed/mount/weedfs_file_read.go

4
weed/mount/weedfs_file_read.go

@ -49,10 +49,14 @@ 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 signal
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
go func() {
select {
case <-cancel:
cancelFunc()
case <-ctx.Done():
// Context already cancelled, exit goroutine
}
}()

Loading…
Cancel
Save