Moved resetLock() to the Load() method ; changed resetLock() to initLock() and changed behavior to not modify the lock if it was already set (not nil)
This commit is contained in:
parent
7b74b9cab5
commit
d1767bbf67
3 changed files with 6 additions and 4 deletions
|
@ -127,7 +127,6 @@ func (container *Container) FromDisk() error {
|
|||
if err := json.Unmarshal(data, container); err != nil {
|
||||
return err
|
||||
}
|
||||
container.State.resetLock()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ func (runtime *Runtime) Load(id string) (*Container, error) {
|
|||
if err := container.FromDisk(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
container.State.initLock()
|
||||
if container.Id != id {
|
||||
return container, fmt.Errorf("Container %s is stored at %s", container.Id, id)
|
||||
}
|
||||
|
|
8
state.go
8
state.go
|
@ -39,9 +39,11 @@ func (s *State) setStopped(exitCode int) {
|
|||
s.broadcast()
|
||||
}
|
||||
|
||||
func (s *State) resetLock() {
|
||||
s.stateChangeLock = &sync.Mutex{}
|
||||
s.stateChangeCond = sync.NewCond(s.stateChangeLock)
|
||||
func (s *State) initLock() {
|
||||
if s.stateChangeLock == nil {
|
||||
s.stateChangeLock = &sync.Mutex{}
|
||||
s.stateChangeCond = sync.NewCond(s.stateChangeLock)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *State) broadcast() {
|
||||
|
|
Loading…
Reference in a new issue