double check the state wasn't created in the short time prior to grabbing the lock
This commit is contained in:
parent
7d6ec431d2
commit
8980b6dc9e
|
@ -118,6 +118,14 @@ func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
|
|||
return parent
|
||||
}
|
||||
|
||||
// Grab the value
|
||||
if err := stateMgr.RefreshState(); err != nil {
|
||||
err = lockUnlock(err)
|
||||
return nil, err
|
||||
}
|
||||
//if this isn't the default state name, we need to create the object so
|
||||
//it's listed by States.
|
||||
if v := stateMgr.State(); v == nil {
|
||||
// If we have no state, we have to create an empty state
|
||||
if err := stateMgr.WriteState(states.NewState()); err != nil {
|
||||
err = lockUnlock(err)
|
||||
|
@ -133,6 +141,7 @@ func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stateMgr, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue