From 32a54df70697056e64dca9ee2b9baa22550c0eb2 Mon Sep 17 00:00:00 2001 From: EaseWay Hu Date: Sat, 8 Aug 2020 16:28:19 -0700 Subject: [PATCH] fix teardown error using a separate context --- pkg/ssh/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/ssh/server.go b/pkg/ssh/server.go index ae10b3f..c340cd2 100644 --- a/pkg/ssh/server.go +++ b/pkg/ssh/server.go @@ -347,7 +347,8 @@ func (c *connection) forwardRun(ctx context.Context, faddr forwardAddr, ln net.L go closeWhenDone(ctx, ln) defer func() { c.removeListener(faddr, ln) - if err := c.server.setupForwarder(ctx, faddr.String(), localAddr, false); err != nil { + // Use a different context as the current one may be already canceled. + if err := c.server.setupForwarder(context.Background(), faddr.String(), localAddr, false); err != nil { c.log("%s teardown error: %v", logPrefix, err) } c.log("%s", logPrefix)