diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-01-24 17:19:35 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-01-24 17:19:35 -0800 |
| commit | 9bcb28a3eabcb2c869afc52da6b0341e8e2d8427 (patch) | |
| tree | f2745de2e6307eebcf936a843f82cbd21de1f1f5 | |
| parent | 2c5eac5705c12b4dc0930d0a27478a73924b9e16 (diff) | |
| download | seaweedfs-9bcb28a3eabcb2c869afc52da6b0341e8e2d8427.tar.xz seaweedfs-9bcb28a3eabcb2c869afc52da6b0341e8e2d8427.zip | |
avoid possible nil reader
fix https://github.com/chrislusf/seaweedfs/issues/1754
| -rw-r--r-- | weed/filesys/filehandle.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 6225ab968..5701b92b7 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -126,12 +126,14 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { fh.f.reader = nil } - if fh.f.reader == nil { + reader := fh.f.reader + if reader == nil { chunkViews := filer.ViewFromVisibleIntervals(fh.f.entryViewCache, 0, math.MaxInt64) - fh.f.reader = filer.NewChunkReaderAtFromClient(fh.f.wfs, chunkViews, fh.f.wfs.chunkCache, fileSize) + reader = filer.NewChunkReaderAtFromClient(fh.f.wfs, chunkViews, fh.f.wfs.chunkCache, fileSize) } + fh.f.reader = reader - totalRead, err := fh.f.reader.ReadAt(buff, offset) + totalRead, err := reader.ReadAt(buff, offset) if err != nil && err != io.EOF { glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err) |
