diff --git a/database/ffldb/blockio.go b/database/ffldb/blockio.go index 2b415a17b0..1a9592691b 100644 --- a/database/ffldb/blockio.go +++ b/database/ffldb/blockio.go @@ -524,6 +524,7 @@ func (s *blockStore) readBlock(hash *chainhash.Hash, loc blockLocation) ([]byte, serializedData := make([]byte, loc.blockLen) n, err := blockFile.file.ReadAt(serializedData, int64(loc.fileOffset)) blockFile.RUnlock() + blockFile.file.Close() if err != nil { str := fmt.Sprintf("failed to read block %s from file %d, "+ "offset %d: %v", hash, loc.blockFileNum, loc.fileOffset, @@ -584,6 +585,7 @@ func (s *blockStore) readBlockRegion(loc blockLocation, offset, numBytes uint32) serializedData := make([]byte, numBytes) _, err = blockFile.file.ReadAt(serializedData, int64(readOffset)) blockFile.RUnlock() + blockFile.file.Close() if err != nil { str := fmt.Sprintf("failed to read region from block file %d, "+ "offset %d, len %d: %v", loc.blockFileNum, readOffset,