mirror of
https://github.com/taigrr/bitcask
synced 2025-01-18 04:03:17 -08:00
Fix issues related to #239 Disable mmap reader for current datafile, which only read from the fd. Co-authored-by: jason3gb <jason3gb@gmail.com> Reviewed-on: https://git.mills.io/prologic/bitcask/pulls/240 Reviewed-by: James Mills <james@mills.io> Reviewed-by: Tai Groot <tai@taigrr.com> Co-authored-by: jason3gb <jason3gb@noreply@mills.io> Co-committed-by: jason3gb <jason3gb@noreply@mills.io>
This commit is contained in:
parent
21a824e13e
commit
2c57c950f8
1
AUTHORS
1
AUTHORS
@ -18,3 +18,4 @@ Yury Fedorov orlangure
|
||||
o2gy84 <o2gy84@gmail.com>
|
||||
garsue <labs.garsue@gmail.com>
|
||||
biozz <ielfimov@gmail.com>
|
||||
jason3gb <jason3gb@gmail.com>
|
@ -74,10 +74,12 @@ func NewDatafile(path string, id int, readonly bool, maxKeySize uint32, maxValue
|
||||
return nil, errors.Wrap(err, "error calling Stat()")
|
||||
}
|
||||
|
||||
if readonly {
|
||||
ra, err = mmap.Open(fn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
offset := stat.Size()
|
||||
|
||||
@ -107,7 +109,9 @@ func (df *datafile) Name() string {
|
||||
|
||||
func (df *datafile) Close() error {
|
||||
defer func() {
|
||||
if df.ra != nil {
|
||||
df.ra.Close()
|
||||
}
|
||||
df.r.Close()
|
||||
}()
|
||||
|
||||
@ -155,7 +159,7 @@ func (df *datafile) ReadAt(index, size int64) (e internal.Entry, err error) {
|
||||
|
||||
b := make([]byte, size)
|
||||
|
||||
if df.w == nil {
|
||||
if df.ra != nil {
|
||||
n, err = df.ra.ReadAt(b, index)
|
||||
} else {
|
||||
n, err = df.r.ReadAt(b, index)
|
||||
|
Loading…
x
Reference in New Issue
Block a user