aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/syndtr/goleveldb/leveldb/version.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-11 18:14:08 +0800
committerGitHub <noreply@github.com>2017-01-11 18:14:08 +0800
commitb52fde7cf7ce50725830a9d7ddb61e0e8094c7cd (patch)
treeb6b5eb1ac26c2aaef462f48d6f6738d588c44ed4 /vendor/github.com/syndtr/goleveldb/leveldb/version.go
parent2b4d0b6ff9954de72177980213e7fee0081973d1 (diff)
parentd78f9b834ade0f1ebcf2532bf90d01c85ad50a8e (diff)
downloadgo-tangerine-b52fde7cf7ce50725830a9d7ddb61e0e8094c7cd.tar.gz
go-tangerine-b52fde7cf7ce50725830a9d7ddb61e0e8094c7cd.tar.zst
go-tangerine-b52fde7cf7ce50725830a9d7ddb61e0e8094c7cd.zip
Merge pull request #3546 from fjl/deps-update
vendor: update dependencies
Diffstat (limited to 'vendor/github.com/syndtr/goleveldb/leveldb/version.go')
-rw-r--r--vendor/github.com/syndtr/goleveldb/leveldb/version.go40
1 files changed, 22 insertions, 18 deletions
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/version.go b/vendor/github.com/syndtr/goleveldb/leveldb/version.go
index c60f12c20..73f272af5 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/version.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/version.go
@@ -34,44 +34,48 @@ type version struct {
cSeek unsafe.Pointer
- closing bool
- ref int
- // Succeeding version.
- next *version
+ closing bool
+ ref int
+ released bool
}
func newVersion(s *session) *version {
return &version{s: s}
}
+func (v *version) incref() {
+ if v.released {
+ panic("already released")
+ }
+
+ v.ref++
+ if v.ref == 1 {
+ // Incr file ref.
+ for _, tt := range v.levels {
+ for _, t := range tt {
+ v.s.addFileRef(t.fd, 1)
+ }
+ }
+ }
+}
+
func (v *version) releaseNB() {
v.ref--
if v.ref > 0 {
return
- }
- if v.ref < 0 {
+ } else if v.ref < 0 {
panic("negative version ref")
}
- nextTables := make(map[int64]bool)
- for _, tt := range v.next.levels {
- for _, t := range tt {
- num := t.fd.Num
- nextTables[num] = true
- }
- }
-
for _, tt := range v.levels {
for _, t := range tt {
- num := t.fd.Num
- if _, ok := nextTables[num]; !ok {
+ if v.s.addFileRef(t.fd, -1) == 0 {
v.s.tops.remove(t)
}
}
}
- v.next.releaseNB()
- v.next = nil
+ v.released = true
}
func (v *version) release() {