• Brad Fitzpatrick's avatar
    net/http/httputil: fix race/crash in previous ReverseProxy change · c870d56f
    Brad Fitzpatrick authored
    The previous ReverseProxy change, CL 137335, introduced a bug which could cause
    a race and/or a crash.
    
    This reliably crashed before:
    
    $ go test -short -race -v -run=TestReverseProxyFlushInterval -count=20 net/http/httputil
    
    The problem was a goroutine was running http.ResponseWriter.Flush
    after the http.Handler's ServeHTTP completed. There was code to
    prevent that (a deferred stop call) but the stop call didn't consider
    the case where time.AfterFunc had already fired off a new goroutine
    but that goroutine hadn't yet scheduled.
    
    Change-Id: I06357908465a3b953efc33e63c70dec19a501adf
    Reviewed-on: https://go-review.googlesource.com/c/140977
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarDmitri Shuralyov <dmitshur@golang.org>
    c870d56f
reverseproxy.go 12.5 KB