From e940e12abcc4571c411905e1971a5f206a403bfb Mon Sep 17 00:00:00 2001 From: David Scott Date: Fri, 22 Apr 2016 15:17:56 +0100 Subject: [PATCH] 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 --- alpine/packages/proxy/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/alpine/packages/proxy/main.go b/alpine/packages/proxy/main.go index a7c125a2a..a7ab17b15 100644 --- a/alpine/packages/proxy/main.go +++ b/alpine/packages/proxy/main.go @@ -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 {