From e7858e78d5df2ee77ca87a7b7251671580f986db Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 19 Feb 2018 16:53:07 +0100 Subject: [PATCH] properly set timeout in dokodemo door --- proxy/dokodemo/dokodemo.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 80e952390..8f834b9a2 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -82,6 +82,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in requestDone := signal.ExecuteAsync(func() error { defer inboundRay.InboundInput().Close() + defer timer.SetTimeout(d.policy().Timeouts.DownlinkOnly) chunkReader := buf.NewReader(conn) @@ -89,12 +90,12 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in return newError("failed to transport request").Base(err) } - timer.SetTimeout(d.policy().Timeouts.DownlinkOnly) - return nil }) responseDone := signal.ExecuteAsync(func() error { + defer timer.SetTimeout(d.policy().Timeouts.UplinkOnly) + var writer buf.Writer if network == net.Network_TCP { writer = buf.NewWriter(conn) @@ -116,8 +117,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in return newError("failed to transport response").Base(err) } - timer.SetTimeout(d.policy().Timeouts.UplinkOnly) - return nil })