mirror of https://github.com/etcd-io/bbolt.git
Detect pages that have multiple flags set.
Signed-off-by: Piotr Tabor <ptab@google.com>pull/358/head
parent
d1aa8034d4
commit
3cbd9c9a44
4
node.go
4
node.go
|
@ -191,9 +191,9 @@ func (n *node) read(p *page) {
|
|||
func (n *node) write(p *page) {
|
||||
// Initialize page.
|
||||
if n.isLeaf {
|
||||
p.flags |= leafPageFlag
|
||||
p.flags = leafPageFlag
|
||||
} else {
|
||||
p.flags |= branchPageFlag
|
||||
p.flags = branchPageFlag
|
||||
}
|
||||
|
||||
if len(n.inodes) >= 0xFFFF {
|
||||
|
|
11
page.go
11
page.go
|
@ -2,7 +2,6 @@ package bbolt
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"unsafe"
|
||||
|
@ -55,9 +54,13 @@ func (p *page) meta() *meta {
|
|||
}
|
||||
|
||||
func (p *page) fastCheck(id pgid) {
|
||||
if p.id != id {
|
||||
log.Panicf("Page expected to be: %v, but self identifies as %v", id, p.id)
|
||||
}
|
||||
_assert(p.id == id, "Page expected to be: %v, but self identifies as %v", id, p.id)
|
||||
// Only one flag of page-type can be set.
|
||||
_assert(p.flags == branchPageFlag ||
|
||||
p.flags == leafPageFlag ||
|
||||
p.flags == metaPageFlag ||
|
||||
p.flags == freelistPageFlag,
|
||||
"page %v: has unexpected type/flags: %x", p.id, p.flags)
|
||||
}
|
||||
|
||||
// leafPageElement retrieves the leaf node by index
|
||||
|
|
Loading…
Reference in New Issue