Commit Graph

20 Commits

Author SHA1 Message Date
Oleksandr Redko
7e3c19ca52 all: correct typos in comments
Change-Id: Idc75240e5546be2f2b091878910339b4967c93c7
GitHub-Last-Rev: c78560c06f
GitHub-Pull-Request: golang/net#166
Reviewed-on: https://go-review.googlesource.com/c/net/+/465715
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-07 17:08:46 +00:00
Bryan C. Mills
e204ce36a2 netutil: in TestLimitListenerSaturation, allow some connections to fail to dial
When the listener saturates, the kernel will typically buffer the
remaining pending connections (so they will eventually succeed in
dialing). However, that behavior is not guaranteed, and it empirically
doesn't always hold: a failure was observed in
https://build.golang.org/log/5ac7312814bcff4841563be043f28aaefa9b3c90.

We do expect to be able to dial at least as many connections as the
listener will accept, and we expect every connection that is accepted
to be served to completion.

Updates golang/go#22926

Change-Id: I4cb39c8f39fda0dcb905f548612ccdf1856f2a66
Reviewed-on: https://go-review.googlesource.com/c/net/+/380155
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-21 21:01:41 +00:00
Bryan C. Mills
5b0dc2dfae netutil: make LimitListener tests more robust
In CL 372495 I cleaned up TestLimitListener so that it would not fail
spuriously. However, upon further thought I realized that the original
test was actually checking two different properties (steady-state
saturation, and actual overload), and the cleaned-up test was only
checking one of those (overload).

This change adds a separate test for steady-state saturation, and
makes the overload test more robust to spurious connections (which
could occur, for example, if another test running on the machine
accidentally dials this test's open port).

The test cleanup also revealed a bad interaction with an existing bug
in the js/wasm net.TCPListener implementation (filed as
golang/go#50216), for which I have added a workaround in
(*limitListener).Accept.

For golang/go#22926

Change-Id: I727050a8254f527c7455de296ed3525b6dc90141
Reviewed-on: https://go-review.googlesource.com/c/net/+/372714
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-05 14:52:11 +00:00
Bryan C. Mills
fe4d628211 netutil: streamline and simplify LimitListener tests
TestLimitListener had made a lot of assumptions about the kernel's
willingness to queue unaccepted connections, and relied on arbitrary
timeouts to shed load if the queue saturates.

This change eliminates the arbitrary timeouts, replacing them with
synchronization and cancellation and leaving only a couple of
arbitrary sleeps (that can be exceeded by arbitrary amounts without
causing the test to fail).

Fixes golang/go#22926

Change-Id: Ibecff6254ec966e1cc98cf96c71493f18d3aaebe
Reviewed-on: https://go-review.googlesource.com/c/net/+/372495
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-16 03:09:14 +00:00
Bryan C. Mills
4852103109 netutil: skip TestLimitListener on plan9
This may be a platform bug, but nobody has investigated it since the
issue was filed in 2017. Skip it to reduce noise from flakes.

For golang/go#22926

Change-Id: I8f310a539992c4552abb50fea3c7adc2149818ef
Reviewed-on: https://go-review.googlesource.com/c/net/+/369054
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-03 18:47:38 +00:00
Russ Cox
5f55cee0dc all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I5b2b7d93424e828a3c5f76ae3f30ab825aca388e
Reviewed-on: https://go-review.googlesource.com/c/net/+/294371
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 03:31:24 +00:00
Lars Lehtonen
f9c8255933 netutil: fix goroutine error handling in test
Change from a done-channel to an error-channel in
TestLimitListenerError() to collect goroutine errors.

Change-Id: I7fb97a4ee18247123c686fd2b3e6f1bfe93de41e
Reviewed-on: https://go-review.googlesource.com/c/net/+/207465
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-16 16:09:21 +00:00
Lars Lehtonen
9aaf51ad5c netutil: fix test to not t.Fatal from goroutine
Change-Id: I07941ecadf7d7268542d13b402436b6111772d02
GitHub-Last-Rev: aece213e50
GitHub-Pull-Request: golang/net#57
Reviewed-on: https://go-review.googlesource.com/c/net/+/203877
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-11-08 22:12:41 +00:00
Mikio Hara
63eda1eb06 all: use of nettest, remove internal/nettest
This change uses the nettest package where possible and removes the
internal/nettest package.

Change-Id: I5615a3ab7957183fecea6b5646df99dbb7c186e2
Reviewed-on: https://go-review.googlesource.com/c/net/+/123057
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-03-27 21:43:58 +00:00
Anand K. Mistry
b3c676e531 netutil: unblock LimitListener.Accept on Close
The net.Listener interface specifies that on Close:
// Any blocked Accept operations will be unblocked and return errors.

Fixes golang/go#24458

Change-Id: I4a61a79db9579a40b536aa65c8077da87aa25156
Reviewed-on: https://go-review.googlesource.com/101535
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-04 17:47:46 +00:00
Dmitri Shuralyov
5d997795f7 all: make copyright headers consistent with one space after period
Go policy has been single space after periods in comments for some time.

The copyright header template at:

	https://golang.org/doc/contribute.html#copyright

also uses a single space.

Make them all consistent.

This CL was generated with:

	perl -i -npe 's,^(// Copyright [0-9]+ The Go Authors\.)  (All rights reserved\.)$,$1 $2,' $(git grep -l -E '^// Copyright [0-9]+ The Go Authors\.  All rights reserved\.$')

Follows https://golang.org/cl/20111.

Change-Id: I66671dddf821f5dc027bc254e0196b3e3a2bdf3b
Reviewed-on: https://go-review.googlesource.com/32878
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-07 23:52:11 +00:00
David Symonds
21af302bb5 netutil: Ditch go1.3 build tag.
We only support Go 1.4+ nowadays; Go 1.2 and earlier are ancient.

Change-Id: I128998550afbf287ad797bb9df905b31af0ff952
Reviewed-on: https://go-review.googlesource.com/17791
Run-TryBot: David Symonds <dsymonds@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-14 00:45:27 +00:00
Mikio Hara
8bfde94a84 netutil: deflake TestLimitListener (again)
This change adds missing accept-queue length check.

Change-Id: Ifefc5c614a1a34af51411976ced096c55b95fb8f
Reviewed-on: https://go-review.googlesource.com/11536
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-27 00:13:35 +00:00
Mikio Hara
af03a19e5e netutil, internal/nettest: deflake TestLimitListener
Change-Id: Ic82974bcafa1723c96ece0b6b0b717b00b27774b
Reviewed-on: https://go-review.googlesource.com/11533
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-26 04:58:29 +00:00
David Symonds
8aa6e209cb net: add import comments.
Change-Id: Ifab0fdaec1d810d268b7c19ad30f476802203b37
2014-12-09 14:17:11 +11:00
Brad Fitzpatrick
a479876f52 netutil: release semaphore on error
Also rewrite it a bit for clarity (IMO).

LGTM=pzm, r
R=pzm, adg, r
CC=golang-codereviews
https://golang.org/cl/96560043
2014-05-22 11:59:35 -07:00
Andrew Gerrand
c286e198d6 go.net/netutil: don't run test on versions of Go prior to 1.3
LGTM=mikioh.mikioh
R=mikioh.mikioh, minux.ma
CC=golang-codereviews
https://golang.org/cl/97970045
2014-05-05 00:38:37 -04:00
Mikio Hara
c5088f4913 go.net/netutil: fix unintentional test deadlock on resource starvation
It's been observed when the node under test has a tiny resource
configutation or package http has changed the behavior of its own
active connection pool.

For example,
http://build.golang.org/log/8912bc0944628cf1b4fe4063a77d36d19f9dd6a3

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/78640043
2014-03-20 04:05:24 +09:00
Andrew Gerrand
ee2e27e1c7 go.net/netutil: LimitListener: avoid deadlock on multiple Close calls
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12967043
2013-08-15 13:52:04 +10:00
Andrew Gerrand
beab8eb873 go.net: add netutil package with LimitListener
Update golang/go#6012

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/12727043
2013-08-14 11:00:04 +10:00