diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-04-12 01:00:12 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-04-12 01:00:12 -0700 |
| commit | b9b7da905ef9ef51d3e060ab1612becd63ab272d (patch) | |
| tree | eb3a0b2be1bcb58dddb41619ac471b280ff32eac | |
| parent | 211d87cf4c6afed1704733654ad3944bf40dd2bd (diff) | |
| download | seaweedfs-b9b7da905ef9ef51d3e060ab1612becd63ab272d.tar.xz seaweedfs-b9b7da905ef9ef51d3e060ab1612becd63ab272d.zip | |
handle nil chunk cache
| -rw-r--r-- | weed/util/chunk_cache/chunk_cache.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go index 682f5185a..ead7a8d0b 100644 --- a/weed/util/chunk_cache/chunk_cache.go +++ b/weed/util/chunk_cache/chunk_cache.go @@ -47,6 +47,10 @@ func NewChunkCache(maxEntries int64, dir string, diskSizeMB int64, segmentCount } func (c *ChunkCache) GetChunk(fileId string) (data []byte) { + if c == nil { + return + } + c.RLock() defer c.RUnlock() @@ -76,6 +80,9 @@ func (c *ChunkCache) GetChunk(fileId string) (data []byte) { } func (c *ChunkCache) SetChunk(fileId string, data []byte) { + if c == nil { + return + } c.Lock() defer c.Unlock() @@ -107,6 +114,9 @@ func (c *ChunkCache) SetChunk(fileId string, data []byte) { } func (c *ChunkCache) Shutdown() { + if c == nil { + return + } c.Lock() defer c.Unlock() for _, diskCache := range c.diskCaches { |
