mirror of https://github.com/docker/docs.git
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
|
@ -127,7 +127,6 @@ func (container *Container) FromDisk() error {
|
||||||
if err := json.Unmarshal(data, container); err != nil {
|
if err := json.Unmarshal(data, container); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.State.resetLock()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ func (runtime *Runtime) Load(id string) (*Container, error) {
|
||||||
if err := container.FromDisk(); err != nil {
|
if err := container.FromDisk(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
container.State.initLock()
|
||||||
if container.Id != id {
|
if container.Id != id {
|
||||||
return container, fmt.Errorf("Container %s is stored at %s", 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()
|
s.broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *State) resetLock() {
|
func (s *State) initLock() {
|
||||||
s.stateChangeLock = &sync.Mutex{}
|
if s.stateChangeLock == nil {
|
||||||
s.stateChangeCond = sync.NewCond(s.stateChangeLock)
|
s.stateChangeLock = &sync.Mutex{}
|
||||||
|
s.stateChangeCond = sync.NewCond(s.stateChangeLock)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *State) broadcast() {
|
func (s *State) broadcast() {
|
||||||
|
|
Loading…
Reference in New Issue