diff --git a/runtime/v2/shim/shim.go b/runtime/v2/shim/shim.go index 9187aa8a0..ed6fb6d6d 100644 --- a/runtime/v2/shim/shim.go +++ b/runtime/v2/shim/shim.go @@ -202,11 +202,10 @@ func (s *Client) Serve() error { // serve serves the ttrpc API over a unix socket at the provided path // this function does not block func serve(ctx context.Context, server *ttrpc.Server, path string) error { - l, path, err := serveListener(path) + l, err := serveListener(path) if err != nil { return err } - logrus.WithField("socket", path).Debug("serving api on abstract socket") go func() { defer l.Close() if err := server.Serve(ctx, l); err != nil && diff --git a/runtime/v2/shim/shim_unix.go b/runtime/v2/shim/shim_unix.go index 4b1ea824a..dd8fd8b66 100644 --- a/runtime/v2/shim/shim_unix.go +++ b/runtime/v2/shim/shim_unix.go @@ -47,7 +47,7 @@ func setupDumpStacks(dump chan<- os.Signal) { signal.Notify(dump, syscall.SIGUSR1) } -func serveListener(path string) (net.Listener, string, error) { +func serveListener(path string) (net.Listener, error) { var ( l net.Listener err error @@ -57,14 +57,15 @@ func serveListener(path string) (net.Listener, string, error) { path = "[inherited from parent]" } else { if len(path) > 106 { - return nil, path, errors.Errorf("%q: unix socket path too long (> 106)", path) + return nil, errors.Errorf("%q: unix socket path too long (> 106)", path) } l, err = net.Listen("unix", "\x00"+path) } if err != nil { - return nil, path, err + return nil, err } - return l, path, nil + logrus.WithField("socket", path).Debug("serving api on abstract socket") + return l, nil } func handleSignals(logger *logrus.Entry, signals chan os.Signal) error { diff --git a/runtime/v2/shim/shim_windows.go b/runtime/v2/shim/shim_windows.go index 0f1616a35..0f20c270d 100644 --- a/runtime/v2/shim/shim_windows.go +++ b/runtime/v2/shim/shim_windows.go @@ -54,20 +54,29 @@ func setupDumpStacks(dump chan<- os.Signal) { // serve serves the ttrpc API over a unix socket at the provided path // this function does not block -func serveListener(path string) (net.Listener, string, error) { +func serveListener(path string) (net.Listener, error) { if path == "" { - return nil, path, errors.New("'socket' must be npipe path") + return nil, errors.New("'socket' must be npipe path") } l, err := winio.ListenPipe(path, nil) if err != nil { - return nil, path, err + return nil, err } - return l, path, nil + logrus.WithField("socket", path).Debug("serving api on npipe socket") + return l, nil } func handleSignals(logger *logrus.Entry, signals chan os.Signal) error { - <-signals - return nil + logger.Info("starting signal loop") + for { + select { + case s := <-signals: + switch s { + case os.Interrupt: + break + } + } + } } func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error { diff --git a/runtime/v2/shim/util_windows.go b/runtime/v2/shim/util_windows.go index b3d71d747..2e760ed39 100644 --- a/runtime/v2/shim/util_windows.go +++ b/runtime/v2/shim/util_windows.go @@ -37,7 +37,7 @@ func SetScore(pid int) error { return nil } -// SocketAddress returns an abstract npipe address +// SocketAddress returns a npipe address func SocketAddress(ctx context.Context, id string) (string, error) { ns, err := namespaces.NamespaceRequired(ctx) if err != nil { @@ -46,7 +46,7 @@ func SocketAddress(ctx context.Context, id string) (string, error) { return fmt.Sprintf("\\\\.\\pipe\\containerd-shim-%s-%s-pipe", ns, id), nil } -// AnonDialer returns a dialer for an abstract npipe +// AnonDialer returns a dialer for a npipe func AnonDialer(address string, timeout time.Duration) (net.Conn, error) { return winio.DialPipe(address, &timeout) } @@ -55,7 +55,7 @@ func AnonDialer(address string, timeout time.Duration) (net.Conn, error) { func NewSocket(address string) (net.Listener, error) { l, err := winio.ListenPipe(address, nil) if err != nil { - return nil, errors.Wrapf(err, "failed to listen to abstract npipe %s", address) + return nil, errors.Wrapf(err, "failed to listen to npipe %s", address) } return l, nil }