aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-07-10 07:35:40 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-07-10 07:35:40 -0600
commitca5f5827102dde61deabe546049045fb4595fd54 (patch)
tree3061c1a474bcaf44f6108d2b67c91493f02eb750
parentAdd 'Intro to BoltDB' link. (diff)
parentFix Windows mmap sizing. (diff)
downloaddedo-ca5f5827102dde61deabe546049045fb4595fd54.tar.gz
dedo-ca5f5827102dde61deabe546049045fb4595fd54.tar.xz
Merge pull request #218 from benbjohnson/fix-win
Fix Windows mmap sizing.
-rw-r--r--db.go2
-rw-r--r--db_test.go3
2 files changed, 3 insertions, 2 deletions
diff --git a/db.go b/db.go
index 6ef35ea..35a56e8 100644
--- a/db.go
+++ b/db.go
@@ -212,7 +212,7 @@ func (db *DB) munmap() error {
// mmapSize determines the appropriate size for the mmap given the current size
// of the database. The minimum size is 4MB and doubles until it reaches 1GB.
func (db *DB) mmapSize(size int) int {
- if size < minMmapSize {
+ if size <= minMmapSize {
return minMmapSize
} else if size < maxMmapStep {
size *= 2
diff --git a/db_test.go b/db_test.go
index e689836..0b4e840 100644
--- a/db_test.go
+++ b/db_test.go
@@ -297,7 +297,8 @@ func TestDB_mmapSize(t *testing.T) {
assert.Equal(t, db.mmapSize(0), minMmapSize)
assert.Equal(t, db.mmapSize(16384), minMmapSize)
assert.Equal(t, db.mmapSize(minMmapSize-1), minMmapSize)
- assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize*2)
+ assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize)
+ assert.Equal(t, db.mmapSize(minMmapSize+1), (minMmapSize*2)+4096)
assert.Equal(t, db.mmapSize(10000000), 20000768)
assert.Equal(t, db.mmapSize((1<<30)-1), 2147483648)
assert.Equal(t, db.mmapSize(1<<30), 1<<31)