mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #13101 from bharaththiruveedula/13092-remove-unwanted-locks
Removing extra locks for Pause and Unpause functions
This commit is contained in:
commit
5e063326a3
2 changed files with 29 additions and 23 deletions
|
@ -767,23 +767,45 @@ func (container *Container) killPossiblyDeadProcess(sig int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Pause() error {
|
func (container *Container) Pause() error {
|
||||||
if container.IsPaused() {
|
container.Lock()
|
||||||
|
defer container.Unlock()
|
||||||
|
|
||||||
|
// We cannot Pause the container which is already paused
|
||||||
|
if container.Paused {
|
||||||
return fmt.Errorf("Container %s is already paused", container.ID)
|
return fmt.Errorf("Container %s is already paused", container.ID)
|
||||||
}
|
}
|
||||||
if !container.IsRunning() {
|
|
||||||
|
// We cannot Pause the container which is not running
|
||||||
|
if !container.Running {
|
||||||
return fmt.Errorf("Container %s is not running", container.ID)
|
return fmt.Errorf("Container %s is not running", container.ID)
|
||||||
}
|
}
|
||||||
return container.daemon.Pause(container)
|
|
||||||
|
if err := container.daemon.execDriver.Pause(container.command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
container.Paused = true
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Unpause() error {
|
func (container *Container) Unpause() error {
|
||||||
if !container.IsPaused() {
|
container.Lock()
|
||||||
return fmt.Errorf("Container %s is not paused", container.ID)
|
defer container.Unlock()
|
||||||
|
|
||||||
|
// We cannot unpause the container which is not paused
|
||||||
|
if !container.Paused {
|
||||||
|
return fmt.Errorf("Container %s is not paused, so what", container.ID)
|
||||||
}
|
}
|
||||||
if !container.IsRunning() {
|
|
||||||
|
// We cannot unpause the container which is not running
|
||||||
|
if !container.Running {
|
||||||
return fmt.Errorf("Container %s is not running", container.ID)
|
return fmt.Errorf("Container %s is not running", container.ID)
|
||||||
}
|
}
|
||||||
return container.daemon.Unpause(container)
|
|
||||||
|
if err := container.daemon.execDriver.Unpause(container.command); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
container.Paused = false
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Kill() error {
|
func (container *Container) Kill() error {
|
||||||
|
|
|
@ -1004,22 +1004,6 @@ func (daemon *Daemon) Run(c *Container, pipes *execdriver.Pipes, startCallback e
|
||||||
return daemon.execDriver.Run(c.command, pipes, startCallback)
|
return daemon.execDriver.Run(c.command, pipes, startCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) Pause(c *Container) error {
|
|
||||||
if err := daemon.execDriver.Pause(c.command); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c.SetPaused()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (daemon *Daemon) Unpause(c *Container) error {
|
|
||||||
if err := daemon.execDriver.Unpause(c.command); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c.SetUnpaused()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (daemon *Daemon) Kill(c *Container, sig int) error {
|
func (daemon *Daemon) Kill(c *Container, sig int) error {
|
||||||
return daemon.execDriver.Kill(c.command, sig)
|
return daemon.execDriver.Kill(c.command, sig)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue