]> Cypherpunks repositories - gostls13.git/commitdiff
net: add test that TCP Close unblocks blocked Reads
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 15 Nov 2016 03:31:47 +0000 (03:31 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 15 Nov 2016 14:22:31 +0000 (14:22 +0000)
I guess this was fixed at some point. Remove a skipped test in
net/http and add an explicit test in net.

Fixes #17695

Change-Id: Idb9f3e236b726bb45098474b830c95c1fce57529
Reviewed-on: https://go-review.googlesource.com/33242
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/http/serve_test.go
src/net/net_test.go

index 54b02a8b2886856a6401e05ff24bf7d0c73b8b44..9715003be909527541d48d755bf4563c799db080 100644 (file)
@@ -4907,9 +4907,6 @@ func get(t *testing.T, c *Client, url string) string {
 // Tests that calls to Server.SetKeepAlivesEnabled(false) closes any
 // currently-open connections.
 func TestServerSetKeepAlivesEnabledClosesConns(t *testing.T) {
-       if runtime.GOOS == "nacl" {
-               t.Skip("skipping on nacl; see golang.org/issue/17695")
-       }
        setParallel(t)
        defer afterTest(t)
        ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
index 640bcac80861cd6188668ab73af846de374e74b5..9a9a7e552c4c444fb17a4cf65494a5b03f7caaff 100644 (file)
@@ -497,3 +497,22 @@ func TestReadTimeoutUnblocksRead(t *testing.T) {
        }
        withTCPConnPair(t, client, server)
 }
+
+// Issue 17695: verify that a blocked Read is woken up by a Close.
+func TestCloseUnblocksRead(t *testing.T) {
+       t.Parallel()
+       server := func(cs *TCPConn) error {
+               // Give the client time to get stuck in a Read:
+               time.Sleep(20 * time.Millisecond)
+               cs.Close()
+               return nil
+       }
+       client := func(ss *TCPConn) error {
+               n, err := ss.Read([]byte{0})
+               if n != 0 || err != io.EOF {
+                       return fmt.Errorf("Read = %v, %v; want 0, EOF", n, err)
+               }
+               return nil
+       }
+       withTCPConnPair(t, client, server)
+}