summaryrefslogtreecommitdiff
path: root/execdriver/lxc
diff options
context:
space:
mode:
authorMichael Crosby <michael@crosbymichael.com>2014-01-13 17:17:59 -0800
committerMichael Crosby <michael@crosbymichael.com>2014-01-17 17:42:22 -0800
commit8c9f62d037a1bc82742ea316adaaf658af56b7c3 (patch)
treeae9f5388bbe1d1bc9891aadf53514e0a3457cd2b /execdriver/lxc
parentc2b602b2ac7b5b3a67dbb7945e97a9f48b1a625e (diff)
downloaddocker-8c9f62d037a1bc82742ea316adaaf658af56b7c3.tar.gz
Improve wait for lxc and driver interface
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Diffstat (limited to 'execdriver/lxc')
-rw-r--r--execdriver/lxc/driver.go42
1 files changed, 8 insertions, 34 deletions
diff --git a/execdriver/lxc/driver.go b/execdriver/lxc/driver.go
index 3b4d385cac..3939841320 100644
--- a/execdriver/lxc/driver.go
+++ b/execdriver/lxc/driver.go
@@ -133,24 +133,17 @@ func (d *driver) Kill(c *execdriver.Process, sig int) error {
return d.kill(c, sig)
}
-func (d *driver) Wait(id string, duration time.Duration) error {
- var (
- killer bool
- done = d.waitLxc(id, &killer)
- )
-
- if duration > 0 {
- select {
- case err := <-done:
+func (d *driver) Wait(id string) error {
+ for {
+ output, err := exec.Command("lxc-info", "-n", id).CombinedOutput()
+ if err != nil {
return err
- case <-time.After(duration):
- killer = true
- return execdriver.ErrWaitTimeoutReached
}
- } else {
- return <-done
+ if !strings.Contains(string(output), "RUNNING") {
+ return nil
+ }
+ time.Sleep(500 * time.Millisecond)
}
- return nil
}
func (d *driver) Version() string {
@@ -207,25 +200,6 @@ func (d *driver) waitForStart(c *execdriver.Process, waitLock chan struct{}) err
return execdriver.ErrNotRunning
}
-func (d *driver) waitLxc(id string, kill *bool) <-chan error {
- done := make(chan error)
- go func() {
- for *kill {
- output, err := exec.Command("lxc-info", "-n", id).CombinedOutput()
- if err != nil {
- done <- err
- return
- }
- if !strings.Contains(string(output), "RUNNING") {
- done <- err
- return
- }
- time.Sleep(500 * time.Millisecond)
- }
- }()
- return done
-}
-
func (d *driver) getInfo(c *execdriver.Process) ([]byte, error) {
return exec.Command("lxc-info", "-s", "-n", c.ID).CombinedOutput()
}