mirror of
https://github.com/golang/go
synced 2024-09-29 14:14:29 -06:00
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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
b687d6a788
commit
9be14c4058
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user