Fix resource leaks (#4737)

* Fix division by zero

* Fix file handle leak

* Fix file handle leak

* Fix file handle leak

* Fix goroutine leak
This commit is contained in:
Nikita Mochalov
2023-08-10 01:30:36 +03:00
committed by GitHub
parent 3365468d0d
commit e6a49dc533
5 changed files with 40 additions and 24 deletions

View File

@@ -2,7 +2,6 @@ package erasure_coding
import (
"fmt"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"os"
"path"
"strconv"
@@ -10,6 +9,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/stats"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
)
type ShardId uint8
@@ -39,6 +39,7 @@ func NewEcVolumeShard(diskType types.DiskType, dirname string, collection string
}
ecdFi, statErr := v.ecdFile.Stat()
if statErr != nil {
_ = v.ecdFile.Close()
return nil, fmt.Errorf("can not stat ec volume shard %s%s: %v", baseFileName, ToExt(int(shardId)), statErr)
}
v.ecdFileSize = ecdFi.Size()