]> Cypherpunks.ru repositories - gostls13.git/commit
net: fix testHookDialTCP race
authorDamien Neil <dneil@google.com>
Tue, 7 Jun 2022 23:53:53 +0000 (16:53 -0700)
committerDamien Neil <dneil@google.com>
Wed, 8 Jun 2022 17:11:00 +0000 (17:11 +0000)
commit432158b69a50e292b625d08dcfacd0604acbabd3
tree018c3c2baa483a04a9ccec620949438277b7706d
parent899f0a29c7be2bba3f8f0bc2987f7c2d70a6c4ec
net: fix testHookDialTCP race

CL 410754 introduces a race accessing the global testHookDialTCP hook.
Avoiding this race is difficult, since Dial can return while
goroutines it starts are still running. Add a version of this
hook to sysDialer, so it can be set on a per-test basis.

(Perhaps other uses of this hook should be moved to use the
sysDialer-local hook, but this change fixes the immediate data race.)

For #52173.

Change-Id: I8fb9be13957e91f92919cae7be213c38ad2af75a
Reviewed-on: https://go-review.googlesource.com/c/go/+/410957
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/net/dial.go
src/net/dial_test.go
src/net/tcpsock_plan9.go
src/net/tcpsock_posix.go