Update libkv godeps

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
Jana Radhakrishnan 2015-10-11 16:02:16 -07:00
parent 9d64e07700
commit 93bc5ed4c7
2 changed files with 27 additions and 1 deletions

View File

@ -146,7 +146,7 @@
},
{
"ImportPath": "github.com/docker/libkv",
"Rev": "9d9710dcf6419a58455d0a80e0a8a21ca5f21a94"
"Rev": "4ca160cf21d4e097725d93a72d7b3937c537cdc2"
},
{
"ImportPath": "github.com/godbus/dbus",

View File

@ -6,6 +6,7 @@ import (
"errors"
"os"
"path/filepath"
"sync"
"sync/atomic"
"time"
@ -43,6 +44,7 @@ type BoltDB struct {
// PersistConnection flag provides an option to override ths behavior.
// ie: open the connection in New and use it till Close is called.
PersistConnection bool
sync.Mutex
}
const (
@ -130,6 +132,8 @@ func (b *BoltDB) Get(key string) (*store.KVPair, error) {
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
if db, err = b.getDBhandle(); err != nil {
return nil, err
@ -169,6 +173,9 @@ func (b *BoltDB) Put(key string, value []byte, opts *store.WriteOptions) error {
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
dbval := make([]byte, libkvmetadatalen)
if db, err = b.getDBhandle(); err != nil {
@ -201,6 +208,9 @@ func (b *BoltDB) Delete(key string) error {
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
if db, err = b.getDBhandle(); err != nil {
return err
}
@ -224,6 +234,8 @@ func (b *BoltDB) Exists(key string) (bool, error) {
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
if db, err = b.getDBhandle(); err != nil {
return false, err
@ -253,6 +265,9 @@ func (b *BoltDB) List(keyPrefix string) ([]*store.KVPair, error) {
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
kv := []*store.KVPair{}
if db, err = b.getDBhandle(); err != nil {
@ -299,6 +314,8 @@ func (b *BoltDB) AtomicDelete(key string, previous *store.KVPair) (bool, error)
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
if previous == nil {
return false, store.ErrPreviousNotSpecified
@ -337,6 +354,9 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
dbval := make([]byte, libkvmetadatalen)
if db, err = b.getDBhandle(); err != nil {
@ -391,6 +411,9 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt
// Close the db connection to the BoltDB
func (b *BoltDB) Close() {
b.Lock()
defer b.Unlock()
if !b.PersistConnection {
b.reset()
} else {
@ -405,6 +428,9 @@ func (b *BoltDB) DeleteTree(keyPrefix string) error {
db *bolt.DB
err error
)
b.Lock()
defer b.Unlock()
if db, err = b.getDBhandle(); err != nil {
return err
}