Skip to content

Commit

Permalink
Update docker with syncpipe changes
Browse files Browse the repository at this point in the history
We removed the syncpipe package and replaced it with specific calls to
create a new *os.File from a specified fd passed to the process.  This
reduced code and an extra object to manage the container's init
lifecycle.

Signed-off-by: Michael Crosby <[email protected]>
  • Loading branch information
crosbymichael committed Nov 6, 2014
1 parent 7f5ebdc commit ed556fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
8 changes: 1 addition & 7 deletions daemon/execdriver/native/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/docker/docker/pkg/reexec"
"github.com/docker/libcontainer"
"github.com/docker/libcontainer/namespaces"
"github.com/docker/libcontainer/syncpipe"
)

func init() {
Expand Down Expand Up @@ -48,12 +47,7 @@ func initializer() {
writeError(err)
}

syncPipe, err := syncpipe.NewSyncPipeFromFd(0, uintptr(*pipe))
if err != nil {
writeError(err)
}

if err := namespaces.Init(container, rootfs, *console, syncPipe, flag.Args()); err != nil {
if err := namespaces.Init(container, rootfs, *console, os.NewFile(uintptr(*pipe), "child"), flag.Args()); err != nil {
writeError(err)
}

Expand Down
10 changes: 2 additions & 8 deletions daemon/execdriver/native/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
package native

import (
"encoding/json"
"os"

"github.com/docker/libcontainer"
"github.com/docker/libcontainer/syncpipe"
)

func findUserArgs() []string {
Expand All @@ -21,15 +21,9 @@ func findUserArgs() []string {
// loadConfigFromFd loads a container's config from the sync pipe that is provided by
// fd 3 when running a process
func loadConfigFromFd() (*libcontainer.Config, error) {
syncPipe, err := syncpipe.NewSyncPipeFromFd(0, 3)
if err != nil {
return nil, err
}

var config *libcontainer.Config
if err := syncPipe.ReadFromParent(&config); err != nil {
if err := json.NewDecoder(os.NewFile(3, "child")).Decode(&config); err != nil {
return nil, err
}

return config, nil
}

0 comments on commit ed556fb

Please sign in to comment.