Commit 9be14c40 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net: add test that TCP Close unblocks blocked Reads

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: default avatarIan Lance Taylor <iant@golang.org>
parent b687d6a7
......@@ -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) {
......
......@@ -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)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment