net: avoid Shutdown during Close

Once we've evicted all the blocked I/O, the ref count
should go to zero quickly, so it should be safe to
postpone the close(2) until then.

Fixes #1898.
Fixes #2116.
Fixes #2122.

R=golang-dev, mikioh.mikioh, bradfitz, fullung, iant
CC=golang-dev
https://golang.org/cl/5649076
This commit is contained in:
Russ Cox 2012-02-14 00:40:37 -05:00
parent b7360b9b06
commit 5e4e3d8e44
15 changed files with 440 additions and 200 deletions

View file

@ -114,6 +114,12 @@ func TestSelfConnect(t *testing.T) {
if testing.Short() {
n = 1000
}
switch runtime.GOOS {
case "darwin", "freebsd", "openbsd", "windows":
// Non-Linux systems take a long time to figure
// out that there is nothing listening on localhost.
n = 100
}
for i := 0; i < n; i++ {
c, err := Dial("tcp", addr)
if err == nil {