diff options
| author | Bruce <half-life@jibudata.com> | 2024-09-14 23:33:35 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-14 08:33:35 -0700 |
| commit | 54282293475a3a25800d96ed0c90cfb1de4ad778 (patch) | |
| tree | a2c82b15c70f9e5ef68aa1805acc27ba405b53ee /weed/util | |
| parent | 881c9a009edf07061c82e45c0add928969481c7e (diff) | |
| download | seaweedfs-54282293475a3a25800d96ed0c90cfb1de4ad778.tar.xz seaweedfs-54282293475a3a25800d96ed0c90cfb1de4ad778.zip | |
fix file read crash (#6021)
Diffstat (limited to 'weed/util')
| -rw-r--r-- | weed/util/chunk_cache/chunk_cache.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go index 37dde1950..7eee41b9b 100644 --- a/weed/util/chunk_cache/chunk_cache.go +++ b/weed/util/chunk_cache/chunk_cache.go @@ -22,9 +22,9 @@ type TieredChunkCache struct { memCache *ChunkCacheInMemory diskCaches []*OnDiskCacheLayer sync.RWMutex - onDiskCacheSizeLimit0 uint64 - onDiskCacheSizeLimit1 uint64 - onDiskCacheSizeLimit2 uint64 + onDiskCacheSizeLimit0 uint64 + onDiskCacheSizeLimit1 uint64 + onDiskCacheSizeLimit2 uint64 maxFilePartSizeInCache uint64 } @@ -42,12 +42,15 @@ func NewTieredChunkCache(maxEntries int64, dir string, diskSizeInUnit int64, uni c.diskCaches[0] = NewOnDiskCacheLayer(dir, "c0_2", diskSizeInUnit*unitSize/8, 2) c.diskCaches[1] = NewOnDiskCacheLayer(dir, "c1_3", diskSizeInUnit*unitSize/4+diskSizeInUnit*unitSize/8, 3) c.diskCaches[2] = NewOnDiskCacheLayer(dir, "c2_2", diskSizeInUnit*unitSize/2, 2) - c.maxFilePartSizeInCache = uint64(unitSize*diskSizeInUnit)/4 + c.maxFilePartSizeInCache = uint64(unitSize*diskSizeInUnit) / 4 return c } func (c *TieredChunkCache) GetMaxFilePartSizeInCache() (answer uint64) { + if c == nil { + return 0 + } return c.maxFilePartSizeInCache } |
