]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: close body in benchmarks
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 17 Feb 2014 02:04:31 +0000 (06:04 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 17 Feb 2014 02:04:31 +0000 (06:04 +0400)
Is it required? Why don't we do it?

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/61150043

src/pkg/net/http/serve_test.go

index f826724a16a0053112e06f1c4454181897003298..54e8c24e832bdcb82dcf58a473680fec11e0f8b3 100644 (file)
@@ -2258,7 +2258,9 @@ func BenchmarkClientServer(b *testing.B) {
                if err != nil {
                        b.Fatal("Get:", err)
                }
+               defer res.Body.Close()
                all, err := ioutil.ReadAll(res.Body)
+               res.Body.Close()
                if err != nil {
                        b.Fatal("ReadAll:", err)
                }
@@ -2301,6 +2303,7 @@ func benchmarkClientServerParallel(b *testing.B, conc int) {
                                        continue
                                }
                                all, err := ioutil.ReadAll(res.Body)
+                               res.Body.Close()
                                if err != nil {
                                        b.Logf("ReadAll: %v", err)
                                        continue
@@ -2338,6 +2341,7 @@ func BenchmarkServer(b *testing.B) {
                                log.Panicf("Get: %v", err)
                        }
                        all, err := ioutil.ReadAll(res.Body)
+                       res.Body.Close()
                        if err != nil {
                                log.Panicf("ReadAll: %v", err)
                        }