Commit Graph

1708 Commits

Author SHA1 Message Date
Bryan C. Mills
eba003a116 ipv6: in PacketConn tests, retry writes that fail with ENOBUFS
In golang/go#37319, TestPacketConnReadWriteMulticastUDP was observed
to occasionally fail with ENOBUFS on macOS.

This change adds a retry loop for that test function. There are some
other related test functions that may also wrap sendmsg, but I have
not observed any ENOBUFS failures for them — I suspect that some
difference in protocol or traffic class prevents this failure mode,
but we can always add more retry loops if we discover that they are
actually needed.

Fixes golang/go#37319.

Change-Id: I99fce94ff10c6f3c09d493712eba782ec8707a58
Reviewed-on: https://go-review.googlesource.com/c/net/+/369742
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>
2021-12-06 22:34:03 +00:00
Bryan C. Mills
266e24b1e4 ipv6: remove arbitrary deadlines from tests
These deadlines were added back in CL 21080043, apparently in an
attempt to increase code coverage numbers. However, nothing in the
tests actually exercises the deadline logic: the tests would pass even
if these methods were no-ops. Their only apparent effect is to make
the tests flaky on slower builders, and to destroy goroutine traces
if the test should ever happen to deadlock.

Updates golang/go#42064
For golang/go#37319

Change-Id: I530a8f3cb80d6d93d1625bc88f0ec7958d4ec35e
Reviewed-on: https://go-review.googlesource.com/c/net/+/366181
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>
2021-12-06 22:32:45 +00:00
Brad Fitzpatrick
012df41ee6 dns/dnsmessage: clarify a few things in docs, fix typo
Change-Id: Id01c6552b85cad0554a86bd4aa4547dbea4983eb
Reviewed-on: https://go-review.googlesource.com/c/net/+/369354
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-05 04:19:11 +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
Michal Hruby
0a0e4e1bb5 net/http2: Fix handling of expect continue
Recent refactoring in the http2 package broke handling of ExpectContinueTimeout, where the client was always waiting for the timeout to pass before sending the body.

Fixes: golang/go#49677

Change-Id: I565299e48313bb905b2655bd52084ea49ab742f3
GitHub-Last-Rev: 587b484079
GitHub-Pull-Request: golang/net#118
Reviewed-on: https://go-review.googlesource.com/c/net/+/363914
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2021-12-01 19:05:59 +00:00
Matthias Frei
a5aa9c730a internal/socket: handle reordering in TestUDP/Messages
TestUDP/Messages and TestUDP/Messages-dialed occasionally failed because
the expected messages were not received in a single RecvMsgs call, or
because the messages were received out of order.

Assuming that both messages are returned immediately from a single
RecvMsgs call was a flawed expectation. Fixed by repeatedly invoking
RecvMsgs until all expected messages have been received.

While it certainly seems unusual that packets are reordered on a
loopback device, it does appear to happen occasionally (on linux-mips).
Fixed by sizing receive buffers such that messages in any order can be
received correctly, and by allowing either order for the reassembled
message.

Combine "Messages" and "Messages-dialed" subtests with a simple
table-driven test, to avoid the repetition. The same "Message" and
"Message-dialed".
Finally, make the test failure messages slightly more useful.

Fixes golang/go#49385

Change-Id: I04463c6ffdf4865d2ccfb8662ab4660bda3b3cbf
GitHub-Last-Rev: d9df27b967
GitHub-Pull-Request: golang/net#119
Reviewed-on: https://go-review.googlesource.com/c/net/+/368094
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-12-01 18:16:15 +00:00
Ian Lance Taylor
d83791d6bc internal/socket: always go through syscall package
Instead of relying on syscall.Syscall, always reach into the syscall
package to call the appropriate functions on Unix systems. We were
already doing this on Darwin and AIX. We also have to do this on
OpenBSD, and it's simpler to do it on Linux 386 and s390x. Rather than
sometimes reach into syscall and sometimes not, just always reach in.

For golang/go#42064

Change-Id: I0adb1c7cc623f2c1247465b3852fefd8d09975d2
Reviewed-on: https://go-review.googlesource.com/c/net/+/366195
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-23 20:30:42 +00:00
Ian Lance Taylor
fe8b969b2d ipv6: OpenBSD does not appear to support multicast loopback
Skip the tests for it, as we already skip them on FreeBSD.

Fixes golang/go#42064

Change-Id: I058f25309020367e686625033b4f25cb614c7f99
Reviewed-on: https://go-review.googlesource.com/c/net/+/366355
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-23 20:29:08 +00:00
Ian Lance Taylor
9e5a29745d route: always go through syscall package
Instead of relying on syscall.Syscall, always reach into the syscall
package to call the appropriate functions on Unix systems. We were
already doing this on Darwin. We also have to do this on
OpenBSD. Rather than sometimes reach into syscall and sometimes not,
just always reach in.

For golang/go#42064

Change-Id: Ie292a56766080d0c5ae6b6723d42b5475128290c
Reviewed-on: https://go-review.googlesource.com/c/net/+/366354
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-23 20:28:48 +00:00
Damien Neil
6a13c67c3c http2: avoid spurious RoundTrip error when server closes and resets stream
Avoid a race condition between RoundTrip and the read loop when the
read loop reads a response followed by an immediate stream reset.

Fixes golang/go#49645

Change-Id: Ifb34e2dcb8cc443d3ff5d562cc032edf09da5307
Reviewed-on: https://go-review.googlesource.com/c/net/+/364834
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-18 16:13:19 +00:00
Damien Neil
47ca1ff314 http2: avoid busy loop when ResponseHeaderTimeout is set
Don't keep reading from respHeaderRecv after the response headers
are received.

Fixes golang/go#49615.

Change-Id: Ib8126c954930011ac09b2cbc70bbbce76531b7db
Reviewed-on: https://go-review.googlesource.com/c/net/+/364574
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-16 23:12:05 +00:00
Heschi Kreinick
e8b54dec6f http2/h2demo: delete
As discussed in golang/go#49301, the service has been shut down. Delete the
source.

Fixes golang/go#49301.

Change-Id: Id987c57d7007d9a75801d1a3a9a229fcd22d69e0
Reviewed-on: https://go-review.googlesource.com/c/net/+/364376
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-16 21:27:03 +00:00
Damien Neil
69e39bad7d http2: close conns after use when req.Close is set
Avoid reusing connections after receiving a response to a request
for which cc.Close is set or a "Connection: close" header is present.

Adjust the tests for connection reuse to test both the case where
new conns are created by the http2 package and when they are
created by the net/http package.

Fixes golang/go#49375

Change-Id: I58594972c832a20b66a3910c17acb51a98a9f7a5
Reviewed-on: https://go-review.googlesource.com/c/net/+/361498
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-12 20:21:33 +00:00
Damien Neil
f0573a1506 http2: avoid spurious context cancelation error from Response.Body.Close
When a request has a deadline set, the net/http package can cancel
the request context after reading an error (including io.EOF) from
the response body. Avoid returning a spurious error from
transportResponseBody if the request context is canceled.

For golang/go#49366.

Change-Id: I645466a1d6e405bdf17b3cc087204e4622a140eb
Reviewed-on: https://go-review.googlesource.com/c/net/+/362354
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-12 20:21:18 +00:00
Frank Chiarulli Jr
58aab5ef25 http2: compare Content-Encoding case-insensitive
RFC7230 states that Content-Encoding should be case insensitive, however the current http2 library only checks for lowercase, this PR checks for gzip using `EqualFold` as the http/1 library does. https://tools.ietf.org/html/rfc7230#section-4

Change-Id: Icfb8eb1e5a7ac2975ff3a06f40dbb5ccae8cd8cb
GitHub-Last-Rev: 61029e9fc8
GitHub-Pull-Request: golang/net#85
Reviewed-on: https://go-review.googlesource.com/c/net/+/259897
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-11 16:01:37 +00:00
Tobias Klauser
e5c9674774 internal/socket, lif: add missing //go:build lines
Change-Id: I62c10c4ddd5cc7a037795db4bcf015ccf9bccb1f
Reviewed-on: https://go-review.googlesource.com/c/net/+/362914
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 08:36:44 +00:00
Damien Neil
ef0fda0de5 dict: document package as frozen
This package was created as an example of use of the textproto package,
and has been essentially unchanged since then. Document it as not accepting
new features.

Change-Id: I692c22836ff5a382e498ca6969c0db9ab694de49
Reviewed-on: https://go-review.googlesource.com/c/net/+/346210
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-09 21:46:57 +00:00
Tiago Peczenyj
df9f909512 publicsuffix: update table with more recent data
update to use a more recent table, since we are using data from April

Change-Id: Iae9187a292eab89718057957ba88be2e2e0ef82a
GitHub-Last-Rev: d97d823825
GitHub-Pull-Request: golang/net#110
Reviewed-on: https://go-review.googlesource.com/c/net/+/344709
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Cherry Mui <cherryyz@google.com>
2021-11-09 21:34:50 +00:00
Roland Shoemaker
6635138e15 http2: fix TLS1.0 and TLS1.1 rejection tests
Fixes golang/go#49442

Change-Id: Idb447aa5d33ba312ce28d8ed7f741be652075b4e
Reviewed-on: https://go-review.googlesource.com/c/net/+/362314
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-08 17:07:45 +00:00
Damien Neil
b53810dc28 http2: don't count aborted streams as active in tests
Deflake TestClientConnCloseAtBody, which assumes all streams
have been fully cleaned up after ClientConn.Close returns.
Only count active streams, not ones in the process of aborting.

Perhaps ClientConn.Close should block until all streams have
been cleaned up, although this could result in Close blocking
indefinitely if a stream is blocked reading from the request body.

Fixes golang/go#49335.

Change-Id: I172e0d3f10875191d29b24598de0abbdeb35e434
Reviewed-on: https://go-review.googlesource.com/c/net/+/361536
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-05 19:24:38 +00:00
Damien Neil
ce137452f9 idna: update from x/text
CL 359634: use nontransitional processing in Go 1.18
CL 317731: fix int32 overflows

Updates golang/go#46001
Updates golang/go#47510
Updates golang/go#28233

Change-Id: I2d9cdf5caa44f7c9b2834a256e7464b6edaae9ef
Reviewed-on: https://go-review.googlesource.com/c/net/+/360381
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-04 17:00:05 +00:00
Damien Neil
7594919abe http2: avoid race between processing END_STREAM and closing Response.Body
When the client gets an END_STREAM from the peer, it causes the
response body to return io.EOF and closes cs.peerClosed.

It is possible for the caller of RoundTrip to read io.EOF from the
response body and end the request by calling Response.Body.Close
before we close cs.peerClosed. In this case, we send a spurious
RST_STREAM to the peer.

Closing cs.peerClosed first reverses the race: This can cause the
response body to return "request canceled" rather than io.EOF.

Close both streams with the connection mutex held.

Fixes golang/go#49314

Change-Id: I75557670497c96dd6ed1b566bb4f0f3106a0c9f9
Reviewed-on: https://go-review.googlesource.com/c/net/+/361267
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-04 16:11:57 +00:00
Damien Neil
4a448f8816 http2: set ContentLength to -1 for HEAD response with no Content-Length
When reading a response to a HEAD request with no Content-Length,
set the Response ContentLength to -1 (unknown) rather than 0.

Fixes failing net/http TestH12_HeadContentLengthNoBody.

Change-Id: I472cbcf555e7f70bc41f58bf96da3d3c5bed9654
Reviewed-on: https://go-review.googlesource.com/c/net/+/360376
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-01 19:34:20 +00:00
Damien Neil
99673261e6 http2: set Response.ContentLength to 0 when headers end stream
When reading a response with no Content-Length and no body, set the
Response ContentLength to 0.

Fixes failing net/http TestH2_204NoBody and TestH2_304_NoBody tests.

Change-Id: I8ded6f8febfce62e00f2c37de65cbb09b306f7c6
Reviewed-on: https://go-review.googlesource.com/c/net/+/359834
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-29 22:46:45 +00:00
Damien Neil
540bb53d3b http2: add Transport.WriteByteTimeout
Add a Transport-level knob to set a timeout for writes to net.Conns.
If a write exceeds the timeout without making any progress (at least
one byte written), the connection is closed.

Fixes golang/go#48830.

Change-Id: If0f57996d11c92bced30e07d1e238cbf8994acb4
Reviewed-on: https://go-review.googlesource.com/c/net/+/354431
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-29 16:03:32 +00:00
Damien Neil
d418f374d3 http2: ignore read errors after closing the request body
We close the request body after receiving an error status code.
This is supposed to cause cs.writeRequestBody to return
errStopReqBodyWrite. Ensure that it does so if it gets an error
reading from the post-close body, rather than returning an
error which causes the entire request to be aborted.

Change-Id: I7c51928cb678f5baf37148f0df6ab196518d39d4
Reviewed-on: https://go-review.googlesource.com/c/net/+/356969
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 06:06:15 +00:00
Alexander Yastrebov
c6ed85c7a1 http/httpproxy: document all loopbacks are special cased not just localhost
Fixes golang/go#33695

Change-Id: I2f7598da7c6fda161ba357a75bba72de2fee8226
GitHub-Last-Rev: 443dbb13b1
GitHub-Pull-Request: golang/net#116
Reviewed-on: https://go-review.googlesource.com/c/net/+/356510
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2021-10-19 23:23:29 +00:00
Damien Neil
4f30a5c013 http2: deflake TestTransportRetriesOnStreamProtocolError
During this test:
  -> client sends req1
  <- server sends req1 headers
  -> client sends req2
  <- server resets req2
  <- server sends END_STREAM for req1
  -> client closes the *server* connection

The flake occurs when the last two steps happen out of order: The
client processes the reset for req2, returns from RoundTrip, and
the test closes the connection before the server writes the last
DATA frame for req1. This can be demonstrated by inserting a 1ms
sleep between WriteRSTStream and WriteData on the server side of
the test.

It isn't clear why the client side of the test is closing the server
side of the connection; it isn't essential to the test in any way.
Remove it.

Fixes golang/go#48994.

Change-Id: If074e45a76205ebd245617ef1b068967a6674b94
Reviewed-on: https://go-review.googlesource.com/c/net/+/356329
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-15 21:04:44 +00:00
Damien Neil
db2dff38ab http2: don't abort half-closed streams on server connection close
If the server sends an END_STREAM for a stream and then closes the
connection, allow the stream to complete normally.

Fixes golang/go#48995

Change-Id: Ia876e6e6e7eb4a0563db74c931c03a44620ece08
Reviewed-on: https://go-review.googlesource.com/c/net/+/356030
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-15 17:46:53 +00:00
Damien Neil
fd004c51d1 http2: on write errors, close ClientConn before returning from RoundTrip
Deflakes TestTransportRoundtripCloseOnWriteError.

Fixes golang/go#48995.

Change-Id: I4384d9091d55307d15fbd44b1b8137dcc8939c86
Reviewed-on: https://go-review.googlesource.com/c/net/+/356029
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-14 22:23:26 +00:00
Damien Neil
2b766c08f1 http2: deflake TestTransportReqBodyAfterResponse_200
Don't send the END_STREAM flag from the server until the client
sends its END_STREAM. Avoids a flaky failure when the client
sends the END_STREAM in a zero-length DATA frame:

  - The server reads bodySize bytes and half-closes the stream.
  - The client's Response.Body returns EOF.
  - The test calls Response.Body.Close.
  - The client resets the stream.

Avoid hanging forever on the client side of the test if the
server side exits with an error.

Fixes golang/go#48970

Change-Id: Ic921a3f60149abbb5434ec7a53985becea7b23c3
Reviewed-on: https://go-review.googlesource.com/c/net/+/355649
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 17:25:44 +00:00
Damien Neil
e13a2654a7 http2: close the Request's Body when aborting a stream
After RoundTrip returns, closing the Response's Body should
interrupt any ongoing write of the request body. Close the
Request's Body to unblock the body writer.

Take additional care around the use of a Request after
its Response's Body has been closed. The RoundTripper contract
permits the caller to modify the request after the Response's
body has been closed.

Updates golang/go#48908.

Change-Id: I261e08eb5d70016b49942d72833f46b2ae83962a
Reviewed-on: https://go-review.googlesource.com/c/net/+/355491
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-13 17:12:55 +00:00
renthraysk
ee2e9a0823 http2: number of allocs reduced from 3852 to 31
buildRootHuffmanNode() was allocating a new node for every leaf of the huffman decoding tree.
This PR allocates an array of nodes for all the leaf nodes, and reuses them.
As buildRootHuffmanNode is only called via sync.Once, it's not significant performance wise, but still seems an unnecessary number of allocations.

benchmark           old ns/op     new ns/op     delta
BenchmarkRoot-4     162847        17911         -89.00%

benchmark           old allocs     new allocs     delta
BenchmarkRoot-4     3852           31             -99.20%

benchmark           old bytes     new bytes     delta
BenchmarkRoot-4     92112         35056         -61.94%

Change-Id: I7c1eae13fb6130090610eec1eb0347d5d1fef20c
GitHub-Last-Rev: f40a4e8530
GitHub-Pull-Request: golang/net#112
Reviewed-on: https://go-review.googlesource.com/c/net/+/346649
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-13 15:36:59 +00:00
Alexander Yastrebov
08712a7432 http2: return unexpected eof on empty response with non-zero content length
Fixes golang/go#46071

Change-Id: I8b8262ba8e28a129f6aacfca43b7b8d9e605a0ce
GitHub-Last-Rev: 11b92cc8ba
GitHub-Pull-Request: golang/net#114
Reviewed-on: https://go-review.googlesource.com/c/net/+/354141
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-13 15:34:56 +00:00
Damien Neil
caeb26a5c8 http2: don't rely on system TCP buffer sizes in TestServer_MaxQueuedControlFrames
This test relies on filling up a TCP write buffer, but buffer sizes aren't
under our control and can be large. Use a net.Conn wrapper that blocks instead.

Change-Id: I72471ef293f906b33f2a0fd81d69a3dd57f32fde
Reviewed-on: https://go-review.googlesource.com/c/net/+/349932
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-11 17:04:08 +00:00
Tobias Klauser
3b03d30599 nettest: simplify iOS detection in TestableNetwork
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

Now that Go 1.16 is the oldest supported release, the ios tag can be
used exclusively in TestableNetwork to detect iOS, increasing test
coverage for darwin/arm64.

For golang/go#45696

Change-Id: If607ff8847ed42160ef5e8260d2a8c21798a164a
Reviewed-on: https://go-review.googlesource.com/c/net/+/354809
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-08 19:48:52 +00:00
Brad Fitzpatrick
59d4e928ea http2: add ClientConnState, ClientConn.State accessor
So ClientConnPool can be implemented with the same functionality
as the built-in one. And for observability.

Change-Id: I855fbac3d9e4c02ab213a3e6a80b00f857648264
Reviewed-on: https://go-review.googlesource.com/c/net/+/354351
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-07 12:55:05 +00:00
Damien Neil
62292e8068 http2: detect write-blocked PING frames
We start the PingTimeout timer before writing a PING frame.
However, writing the frame can block indefinitely (either
acquiring cc.wmu or writing to the conn), and the timer is
not checked until after the frame is written.

Move PING writes into a separate goroutine, so we can detect
write-blocked connections.

Fixes golang/go#48810.

Change-Id: Ifd67fa23799e750d02754e1fe5d32719f60faed4
Reviewed-on: https://go-review.googlesource.com/c/net/+/354389
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-06 19:02:31 +00:00
Damien Neil
d2e5035098 http2: avoid race in TestTransportReqBodyAfterResponse_403.
This test sends a request with a 10MiB body, reads a 403 response
while the body is still being written, and closes the response body.
It then verifies that the full request body was not written, since
reading a response code >=300 interrupts body writes.

This can be racy: We process the status code and interrupt the body
write in RoundTrip, but it is possible for the body write to complete
before RoundTrip looks at the response.

Adjust the test to have more control over the request body:
Only provide half the Request.Body until after the response headers
have been received.

Fixes golang/go#48792.

Change-Id: Id4802b04a50f34f6af28f4eb93e37ef70a33a068
Reviewed-on: https://go-review.googlesource.com/c/net/+/354130
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-05 21:50:30 +00:00
Damien Neil
d4b1ae081e http2: avoid clientConnPool panic when NewClientConn fails
Change-Id: Id5c1c40f9d8a07b7e6d399cc4e9f60ebe10ccf49
Reviewed-on: https://go-review.googlesource.com/c/net/+/353881
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-05 00:13:12 +00:00
Damien Neil
69340ce214 http2: avoid extra GetConn trace call
CL 352469 inverts the case in shouldTraceGetConn: We want to call GetConn
for connections that have been previously used, but it calls GetConn
only on approximately the first use. "Approximately", because it uses
cc.nextStreamID to determine if the connection has been used, which
is racy.

Restructure the decision to call GetConn to track a per-ClientConn bool
indicating whether GetConn has already been called for this connection.
Set this bool for connections received from net/http, clear it after the
first use of the connection.

Fixes net/http's TestTransportEventTrace_h2.

Change-Id: I8e3dbba7cfbce9acd3612e39b6b6ee558bbfc864
Reviewed-on: https://go-review.googlesource.com/c/net/+/353875
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-04 22:05:34 +00:00
Damien Neil
b30845b58a http2: fix typo in doRequest doc comment
Change-Id: I46dc54abeb978a2458bbc41b471a8d9b6613cb0d
Reviewed-on: https://go-review.googlesource.com/c/net/+/353872
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-04 19:50:52 +00:00
Damien Neil
cedda3a722 http2: refactor request write flow
Move the entire request write into a new writeRequest function,
which runs as its own goroutine.

The writeRequest function handles all indefintely-blocking
operations (in particular, network writes), as well as all
post-request cleanup: Closing the request body, sending a
RST_STREAM when necessary, releasing the concurrency slot
held by the stream, etc.

Consolidates several goroutines used to wait for stream
slots, write the body, and close response bodies.

Ensures that RoundTrip does not block past request cancelation.

Change-Id: Iaf8bb3e17de89384b031ec4f324918b5720f5877
Reviewed-on: https://go-review.googlesource.com/c/net/+/353390
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-04 16:44:53 +00:00
Michael Fraenkel
e81a3d93ec http2: remove PingTimeout from TestTransportPingWhenReading
Use the default PingTimeout since it has no bearing on the test. A small
value can cause a failure on slower machines. Rely on the deadline to
determine a sufficient amount of time to complete.

Fixes golang/go#48668

Change-Id: I9389777fa00ed5193f1fc7ae04d2e2134114c675
Reviewed-on: https://go-review.googlesource.com/c/net/+/352970
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-29 19:35:57 +00:00
Brad Fitzpatrick
d455829e37 http2: add error counter to one missing processHeaders error path
And unrelated typo fix.

Updates golang/go#48675

Change-Id: Id90e0e76e514ba550fa2d3c9e1104ebfd4c23a9b
Reviewed-on: https://go-review.googlesource.com/c/net/+/353031
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
2021-09-29 16:15:16 +00:00
Brad Fitzpatrick
7d9f5e0b76 http2: wire up Transport and Server's CountError to frame parser code
So all frame parse errors are annotated and flow into the transport
or server's error counters.

Change-Id: I1e287fe33d422f97075029201976b009218852da
Reviewed-on: https://go-review.googlesource.com/c/net/+/352649
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-09-28 04:43:08 +00:00
Brad Fitzpatrick
4e4d966f74 http2: fix Transport connection pool TOCTOU max concurrent stream bug
Change-Id: I3e02072403f2f40ade4ef931058bbb5892776754
Reviewed-on: https://go-review.googlesource.com/c/net/+/352469
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-27 18:15:40 +00:00
Brad Fitzpatrick
76eb614f96 http2: shut down idle Transport connections after protocol errors
Change-Id: Ic4e85cdc75b4baef7cd61a65b1b09f430a2ffc4b
Reviewed-on: https://go-review.googlesource.com/c/net/+/352449
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-09-27 16:17:02 +00:00
Damien Neil
3ad01bbaa1 http2: remove check for read-after-close of request bodies
Aborting a request currently races with writes of the request
body, so abortRequestBodyWrite can close the body before writeRequestBody
reads from it.

Fixes golang/go#48555.

Change-Id: I5362283f4066611aeecbc48b400d79cfa0b4b284
Reviewed-on: https://go-review.googlesource.com/c/net/+/351972
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-24 15:19:03 +00:00
Damien Neil
cf34111cab http: fix race in DATA frame padding refund
Move flow adjustment back under cc.mu.

Fixes golang/go#48491.

Change-Id: Idb762091cfeb55c18bc74389e62193f81438624f
Reviewed-on: https://go-review.googlesource.com/c/net/+/351950
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-24 05:40:57 +00:00