From bd68b8abc2e3ceaa3b9bde98568a4a9af8bde40f Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Mon, 29 Feb 2016 12:06:57 -0300 Subject: net/http: TimeoutHandler should start timer when serving request TimeoutHandler was starting the Timer when the handler was created, instead of when serving a request. It also was sharing it between multiple requests, which is incorrect, as the requests might start at different times. Store the timeout duration and create the Timer when ServeHTTP is called. Different requests will have different timers. The testing plumbing was simplified to store the channel used to control when timeout happens. It overrides the regular timer. Fixes #14568. Change-Id: I4bd51a83f412396f208682d3ae5e382db5f8dc81 Reviewed-on: https://go-review.googlesource.com/20046 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/net/http/export_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/net/http/export_test.go') diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go index e14181a21b..94d55ab2f6 100644 --- a/src/net/http/export_test.go +++ b/src/net/http/export_test.go @@ -59,9 +59,9 @@ func SetTestHookServerServe(fn func(*Server, net.Listener)) { testHookServerServ func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler { return &timeoutHandler{ - handler: handler, - timeout: func() <-chan time.Time { return ch }, - // (no body and nil cancelTimer) + handler: handler, + testTimeout: ch, + // (no body) } } -- cgit v1.3