1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Adding state to exec commands to prevent multiple starts of a single exec command.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
Vishnu Kannan 2014-09-15 23:14:04 +00:00
parent bfebdfde78
commit 39030382c4

View file

@ -18,7 +18,9 @@ import (
)
type execConfig struct {
sync.Mutex
ID string
Running bool
ProcessConfig execdriver.ProcessConfig
StreamConfig
OpenStdin bool
@ -128,6 +130,7 @@ func (d *Daemon) ContainerExecCreate(job *engine.Job) engine.Status {
StreamConfig: StreamConfig{},
ProcessConfig: processConfig,
Container: container,
Running: false,
}
d.registerExecCommand(execConfig)
@ -149,11 +152,20 @@ func (d *Daemon) ContainerExecStart(job *engine.Job) engine.Status {
execName = job.Args[0]
)
if execName == "" {
return job.Errorf("ExecName not specified. Cannot start exec command")
execConfig, err := d.getExecConfig(execName)
if err != nil {
return job.Error(err)
}
execConfig, err := d.getExecConfig(execName)
func() {
execConfig.Lock()
defer execConfig.Unlock()
if execConfig.Running {
err = fmt.Errorf("Error: Exec command %s is already running", execName)
}
execConfig.Running = true
}()
if err != nil {
return job.Error(err)
}