Commit 8cd55615 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: fix Server.Close double Lock

Fixes #17878

Change-Id: I062ac514239068c58175c9ee7964b3590f956a82
Reviewed-on: https://go-review.googlesource.com/33026
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 8d0c1054
......@@ -4988,3 +4988,10 @@ func testServerShutdown(t *testing.T, h2 bool) {
t.Fatal("second request should fail. server should be shut down")
}
}
// Issue 17878: tests that we can call Close twice.
func TestServerCloseDeadlock(t *testing.T) {
var s Server
s.Close()
s.Close()
}
......@@ -2362,7 +2362,7 @@ func (s *Server) closeDoneChanLocked() {
// regardless of their state. For a graceful shutdown, use Shutdown.
func (s *Server) Close() error {
s.mu.Lock()
defer s.mu.Lock()
defer s.mu.Unlock()
s.closeDoneChanLocked()
err := s.closeListenersLocked()
for c := range s.activeConn {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment