diff options
author | Lantao Liu <lantaol@google.com> | 2019-05-10 18:27:49 -0700 |
---|---|---|
committer | Ian Lewis <ianlewis@google.com> | 2019-05-11 10:27:49 +0900 |
commit | 97875daf63d03cda6ff3c4f393a004a8295a748e (patch) | |
tree | 30dce772c1d7bb9d77fab8b224675630e3c10b2d /vendor/github.com/containerd/ttrpc/server.go | |
parent | 14f1de4a45daa75ef016fabb56d86cbd9b902504 (diff) |
Port shim fix (#27)
Port shim fixes containerd/containerd#3264, containerd/containerd#3264
Update containerd to newest release/1.2 commit.
Diffstat (limited to 'vendor/github.com/containerd/ttrpc/server.go')
-rw-r--r-- | vendor/github.com/containerd/ttrpc/server.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/vendor/github.com/containerd/ttrpc/server.go b/vendor/github.com/containerd/ttrpc/server.go index 263cb4583..40804eac0 100644 --- a/vendor/github.com/containerd/ttrpc/server.go +++ b/vendor/github.com/containerd/ttrpc/server.go @@ -414,6 +414,9 @@ func (c *serverConn) run(sctx context.Context) { case request := <-requests: active++ go func(id uint32) { + ctx, cancel := getRequestContext(ctx, request.req) + defer cancel() + p, status := c.server.services.call(ctx, request.req.Service, request.req.Method, request.req.Payload) resp := &Response{ Status: status.Proto(), @@ -454,3 +457,15 @@ func (c *serverConn) run(sctx context.Context) { } } } + +var noopFunc = func() {} + +func getRequestContext(ctx context.Context, req *Request) (retCtx context.Context, cancel func()) { + cancel = noopFunc + if req.TimeoutNano == 0 { + return ctx, cancel + } + + ctx, cancel = context.WithTimeout(ctx, time.Duration(req.TimeoutNano)) + return ctx, cancel +} |