proxy: listen on vsock before requesting a connection

The 9P operations tell the host to connect to the vsock port in the
UDP case, so always listen before sending the 9P request.

Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
David Scott 2016-04-22 15:17:56 +01:00
parent caeb0d53cc
commit e940e12abc

View File

@ -14,17 +14,17 @@ import (
func main() {
host, port, container := parseHostContainerAddrs()
p, err := libproxy.NewProxy(&vsock.VsockAddr{Port: uint(port)}, container)
if err != nil {
sendError(err)
}
ctl, err := exposePort(host, port)
if err != nil {
sendError(err)
}
p, err := libproxy.NewProxy(&vsock.VsockAddr{Port: uint(port)}, container)
if err != nil {
sendError(err)
}
go handleStopSignals(p)
// TODO: avoid this line if we are running in a TTY
sendOK()
p.Run()
ctl.Close() // ensure ctl remains alive and un-GCed until here
@ -32,7 +32,7 @@ func main() {
}
func exposePort(host net.Addr, port int) (*os.File, error) {
name := host.String()
name := host.Network() + ":" + host.String()
log.Printf("exposePort %s\n", name)
err := os.Mkdir("/port/"+name, 0)
if err != nil {