update locks
This commit is contained in:
18
box.go
18
box.go
@@ -21,6 +21,16 @@ type Box struct {
|
||||
mx sync.Mutex
|
||||
}
|
||||
|
||||
func (b *Box) Lock() {
|
||||
log.WithFields(log.Fields{"name": b.name}).Debugf("starting")
|
||||
b.mx.Lock()
|
||||
}
|
||||
|
||||
func (b *Box) Unlock() {
|
||||
log.WithFields(log.Fields{"name": b.name}).Debugf("starting")
|
||||
b.mx.Unlock()
|
||||
}
|
||||
|
||||
func (c *Config) NewBox(name, addr, user, key string) (b *Box, err error) {
|
||||
log.WithFields(log.Fields{"name": name, "addr": addr, "user": user, "key": key}).Debugf("starting")
|
||||
defer log.WithFields(log.Fields{"name": name, "addr": addr, "user": user, "key": key}).Debugf("done")
|
||||
@@ -60,8 +70,8 @@ func (b *Box) Open() error {
|
||||
log.WithFields(log.Fields{"name": b.name}).Debugf("starting")
|
||||
defer log.WithFields(log.Fields{"name": b.name}).Debugf("done")
|
||||
|
||||
b.mx.Lock()
|
||||
defer b.mx.Unlock()
|
||||
b.Lock()
|
||||
defer b.Unlock()
|
||||
|
||||
if b.online {
|
||||
return nil
|
||||
@@ -89,8 +99,8 @@ func (b *Box) Close() error {
|
||||
log.WithFields(log.Fields{"name": b.name}).Debugf("starting")
|
||||
defer log.WithFields(log.Fields{"name": b.name}).Debugf("done")
|
||||
|
||||
b.mx.Lock()
|
||||
defer b.mx.Unlock()
|
||||
b.Lock()
|
||||
defer b.Unlock()
|
||||
|
||||
if !b.online {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user