]> Cypherpunks repositories - gostls13.git/commit
net: delete usableLocalPort from test
authorRuss Cox <rsc@golang.org>
Wed, 7 Mar 2012 17:06:22 +0000 (12:06 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 7 Mar 2012 17:06:22 +0000 (12:06 -0500)
commita385f38dfa0e05ef51422e2910e0928062258339
treef3c61536b3a7981aa61d946a1d141e8071738cc1
parent562bccf89e0cc7ca7e62cb1cde50aea6a231ad19
net: delete usableLocalPort from test

The old way to find a port was to listen :0 and then
look at what port it picked, close the listener, and then
immediately try to listen on that port.

On some Windows 7 machines that sequence fails at
the second listen, because the first one is still lingering
in the TCP/IP stack somewhere.  (Ironically, most of these
are used in tests of a "second listen", which in this case
ends up being the third listen.)

Instead of this race, just return the listener from the
function, replacing usableLocalPort+Listen with
usableListenPort.

Fixes #3219.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5769045
src/pkg/net/unicast_test.go