diff options
Diffstat (limited to 'src/net/http/httptest/server.go')
-rw-r--r-- | src/net/http/httptest/server.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/net/http/httptest/server.go b/src/net/http/httptest/server.go index 65165d9eb3..a02a6d64c3 100644 --- a/src/net/http/httptest/server.go +++ b/src/net/http/httptest/server.go @@ -316,6 +316,13 @@ func (s *Server) wrap() { s.Config.ConnState = func(c net.Conn, cs http.ConnState) { s.mu.Lock() defer s.mu.Unlock() + + // Keep Close from returning until the user's ConnState hook + // (if any) finishes. Without this, the call to forgetConn + // below might send the count to 0 before we run the hook. + s.wg.Add(1) + defer s.wg.Done() + switch cs { case http.StateNew: s.wg.Add(1) |