aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/syndtr/goleveldb/leveldb/version.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-11 02:33:17 +0800
committerFelix Lange <fjl@twurst.com>2017-01-11 05:33:24 +0800
commitd78f9b834ade0f1ebcf2532bf90d01c85ad50a8e (patch)
treedd03906433e1032a0b185910773206246d8a1556 /vendor/github.com/syndtr/goleveldb/leveldb/version.go
parent02b67558e8eaa7b34a28b8dd0223824bbbb52349 (diff)
downloadgo-tangerine-d78f9b834ade0f1ebcf2532bf90d01c85ad50a8e.tar.gz
go-tangerine-d78f9b834ade0f1ebcf2532bf90d01c85ad50a8e.tar.zst
go-tangerine-d78f9b834ade0f1ebcf2532bf90d01c85ad50a8e.zip
vendor: update all dependencies except Azure SDK
The Azure SDK doesn't support Go 1.5 anymore. We can't upgrade it until Go 1.8 comes out.
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() {