• Daniel Morsing's avatar
    net/http: silence race detector on client header timeout test · 516f0d1c
    Daniel Morsing authored
    When running the client header timeout test, there is a race between
    us timing out and waiting on the remaining requests to be serviced. If
    the client times out before the server blocks on the channel in the
    handler, we will be simultaneously adding to a waitgroup with the
    value 0 and waiting on it when we call TestServer.Close().
    
    This is largely a theoretical race. We have to time out before we
    enter the handler and the only reason we would time out if we're
    blocked on the channel. Nevertheless, make the race detector happy
    by turning the close into a channel send. This turns the defer call
    into a synchronization point and we can be sure that we've entered
    the handler before we close the server.
    
    Fixes #10780
    
    Change-Id: Id73b017d1eb7503e446aa51538712ef49f2f5c9e
    Reviewed-on: https://go-review.googlesource.com/9905Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    516f0d1c
client_test.go 28.8 KB