mirror of https://github.com/golang/go.git
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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
8d0c105407
commit
8cd55615d4
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue