aboutsummaryrefslogtreecommitdiffstats
path: root/consensus
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-14 16:32:47 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-04-14 16:32:47 +0800
commit65e1095c3f86e46c9741b95e7f856312d74c7501 (patch)
tree8f28a3db4fe907be2c77c4fc607712d805326d4c /consensus
parentee05cc4a2738130315a689351cc536fdb1f4bbab (diff)
downloaddexon-65e1095c3f86e46c9741b95e7f856312d74c7501.tar
dexon-65e1095c3f86e46c9741b95e7f856312d74c7501.tar.gz
dexon-65e1095c3f86e46c9741b95e7f856312d74c7501.tar.bz2
dexon-65e1095c3f86e46c9741b95e7f856312d74c7501.tar.lz
dexon-65e1095c3f86e46c9741b95e7f856312d74c7501.tar.xz
dexon-65e1095c3f86e46c9741b95e7f856312d74c7501.tar.zst
dexon-65e1095c3f86e46c9741b95e7f856312d74c7501.zip
consensus/ethash: close mmap before rename, windows limitation
Diffstat (limited to 'consensus')
-rw-r--r--consensus/ethash/ethash.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go
index d284e7b00..b028f50e6 100644
--- a/consensus/ethash/ethash.go
+++ b/consensus/ethash/ethash.go
@@ -130,13 +130,16 @@ func memoryMapAndGenerate(path string, size uint64, generator func(buffer []uint
data := buffer[len(dumpMagic):]
generator(data)
- if err := mem.Flush(); err != nil {
- mem.Unmap()
- dump.Close()
+ if err := mem.Unmap(); err != nil {
+ return nil, nil, nil, err
+ }
+ if err := dump.Close(); err != nil {
+ return nil, nil, nil, err
+ }
+ if err := os.Rename(temp, path); err != nil {
return nil, nil, nil, err
}
- os.Rename(temp, path)
- return dump, mem, data, nil
+ return memoryMap(path)
}
// cache wraps an ethash cache with some metadata to allow easier concurrent use.