]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/httptest: close client connections in separate goroutines
authorYasha Bubnov <girokompass@gmail.com>
Mon, 28 Nov 2016 20:16:16 +0000 (23:16 +0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 26 Jun 2017 18:31:26 +0000 (18:31 +0000)
The existing implementation sequentially closes connection in the loop
and until the previous client connections is not closed the next one
would not be processed. Instead, the algorithm modified to spawn the
function that closes single connection in a standalone goroutine, thus
making at least a try to close it.

Change-Id: Ib96b5b477f841926450d122b67f14f1a2da36ee1
Reviewed-on: https://go-review.googlesource.com/33614
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/httptest/server.go

index 549ef0462389c93afcd3cd2eca3bdc8b11cce00a..1baec23d57e08440c8f6785a4ee79369a29d526c 100644 (file)
@@ -235,7 +235,7 @@ func (s *Server) CloseClientConnections() {
        nconn := len(s.conns)
        ch := make(chan struct{}, nconn)
        for c := range s.conns {
-               s.closeConnChan(c, ch)
+               go s.closeConnChan(c, ch)
        }
        s.mu.Unlock()