Sfoglia il codice sorgente

Remove goroutine leak upon error

Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
Guillaume J. Charmes 11 anni fa
parent
commit
721562f296
2 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 3 0
      execdriver/lxc/driver.go
  2. 6 0
      server.go

+ 3 - 0
execdriver/lxc/driver.go

@@ -168,6 +168,9 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
 	// Poll lxc for RUNNING status
 	pid, err := d.waitForStart(c, waitLock)
 	if err != nil {
+		if c.Process != nil {
+			c.Process.Kill()
+		}
 		return -1, err
 	}
 	c.ContainerPid = pid

+ 6 - 0
server.go

@@ -2384,7 +2384,13 @@ func (srv *Server) IsRunning() bool {
 }
 
 func (srv *Server) Close() error {
+	if srv == nil {
+		return nil
+	}
 	srv.SetRunning(false)
+	if srv.runtime == nil {
+		return nil
+	}
 	return srv.runtime.Close()
 }