]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: prevent infinite wait during TestMissingStatusNoPanic
authorMichael Fraenkel <michael.fraenkel@gmail.com>
Thu, 13 May 2021 15:41:45 +0000 (09:41 -0600)
committerDamien Neil <dneil@google.com>
Fri, 14 May 2021 16:42:01 +0000 (16:42 +0000)
If the client request never makes it to the server, the outstanding
accept is never broken. Change the test to always close the listening
socket when the client request completes.

Updates #45358

Change-Id: I744a91dfa11704e7e528163d7669c394e90456dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/319275
Trust: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/net/http/transport_test.go

index 5b6a5aa992557d664b65580574799ec38d31ccec..dcaacece617504b8f7e6b195c43cc121e9daec47 100644 (file)
@@ -5322,7 +5322,6 @@ func TestMissingStatusNoPanic(t *testing.T) {
 
        ln := newLocalListener(t)
        addr := ln.Addr().String()
-       shutdown := make(chan bool, 1)
        done := make(chan bool)
        fullAddrURL := fmt.Sprintf("http://%s", addr)
        raw := "HTTP/1.1 400\r\n" +
@@ -5334,10 +5333,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
                "Aloha Olaa"
 
        go func() {
-               defer func() {
-                       ln.Close()
-                       close(done)
-               }()
+               defer close(done)
 
                conn, _ := ln.Accept()
                if conn != nil {
@@ -5368,7 +5364,7 @@ func TestMissingStatusNoPanic(t *testing.T) {
                t.Errorf("got=%v want=%q", err, want)
        }
 
-       close(shutdown)
+       ln.Close()
        <-done
 }