From 6d171bc7724ce30bb523b5c03601b92729b2d4c3 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 15 Jan 2020 06:38:16 -0800 Subject: [release-branch.go1.13] runtime: ignore power notification error seen on Windows Docker Updates #36557 Fixes #36575 Change-Id: Ia8125f382d5e14e5612da811268a58971cc9ac08 Reviewed-on: https://go-review.googlesource.com/c/go/+/214917 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick Reviewed-by: Jason A. Donenfeld Reviewed-by: Austin Clements (cherry picked from commit d2de9bd59c068c1bfcb4293de4286196dacf2e43) Reviewed-on: https://go-review.googlesource.com/c/go/+/215002 --- src/runtime/os_windows.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index 6897933e30..2cf81f61a9 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -263,8 +263,9 @@ func loadOptionalSyscalls() { func monitorSuspendResume() { const ( - _DEVICE_NOTIFY_CALLBACK = 2 - _ERROR_FILE_NOT_FOUND = 2 + _DEVICE_NOTIFY_CALLBACK = 2 + _ERROR_FILE_NOT_FOUND = 2 + _ERROR_INVALID_PARAMETERS = 87 ) type _DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS struct { callback uintptr @@ -302,6 +303,10 @@ func monitorSuspendResume() { // also have their clock on "program time", and therefore // don't want or need this anyway. return + case _ERROR_INVALID_PARAMETERS: + // This is seen when running in Windows Docker. + // See issue 36557. + return default: println("runtime: PowerRegisterSuspendResumeNotification failed with errno=", ret) throw("runtime: PowerRegisterSuspendResumeNotification failure") -- cgit v1.2.3-54-g00ecf From 17ac3f63480020773f1fe0ed77f05f0d37869196 Mon Sep 17 00:00:00 2001 From: Katie Hockman Date: Wed, 5 Feb 2020 14:18:20 -0500 Subject: [release-branch.go1.13] crypto/x509: fix godoc for MarshalPKCS8PrivateKey Updates #36735 Fixes #37067 Change-Id: I93f005d78f4bfac773272995b165172461bae92f Reviewed-on: https://go-review.googlesource.com/c/go/+/217917 Run-TryBot: Katie Hockman TryBot-Result: Gobot Gobot Reviewed-by: Filippo Valsorda (cherry picked from commit 7a36fa400286ca51192a7661a7ffbf9a39c396b3) Reviewed-on: https://go-review.googlesource.com/c/go/+/217998 --- src/crypto/x509/pkcs8.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/x509/pkcs8.go b/src/crypto/x509/pkcs8.go index d37fc9e1b3..ec4ab10c57 100644 --- a/src/crypto/x509/pkcs8.go +++ b/src/crypto/x509/pkcs8.go @@ -79,7 +79,7 @@ func ParsePKCS8PrivateKey(der []byte) (key interface{}, err error) { } } -// MarshalPKCS8PrivateKey converts an RSA private key to PKCS#8, ASN.1 DER form. +// MarshalPKCS8PrivateKey converts a private key to PKCS#8, ASN.1 DER form. // // The following key types are currently supported: *rsa.PrivateKey, *ecdsa.PrivateKey // and ed25519.PrivateKey. Unsupported key types result in an error. -- cgit v1.2.3-54-g00ecf From 224a180deb2170478ebc516f12769f4f801d1c6a Mon Sep 17 00:00:00 2001 From: Michael Fraenkel Date: Fri, 18 Oct 2019 22:19:59 -0400 Subject: [release-branch.go1.13] net/http: only decrement connection count if we removed a connection The connection count must only be decremented if the persistent connection was also removed. Fixes #36583 Change-Id: I5070717d5d9effec78016005fa4910593500c8cf Reviewed-on: https://go-review.googlesource.com/c/go/+/202087 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-on: https://go-review.googlesource.com/c/go/+/215177 Run-TryBot: Alexander Rakoczy Reviewed-by: Alexander Rakoczy --- src/net/http/transport.go | 15 +++++++---- src/net/http/transport_test.go | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 903e0b51ef..db8ec4b2c6 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -542,8 +542,9 @@ func (t *Transport) roundTrip(req *Request) (*Response, error) { _, isH2DialError := pconn.alt.(http2erringRoundTripper) if http2isNoCachedConnError(err) || isH2DialError { - t.removeIdleConn(pconn) - t.decConnsPerHost(pconn.cacheKey) + if t.removeIdleConn(pconn) { + t.decConnsPerHost(pconn.cacheKey) + } } if !pconn.shouldRetryRequest(req, err) { // Issue 16465: return underlying net.Conn.Read error from peek, @@ -966,26 +967,28 @@ func (t *Transport) queueForIdleConn(w *wantConn) (delivered bool) { } // removeIdleConn marks pconn as dead. -func (t *Transport) removeIdleConn(pconn *persistConn) { +func (t *Transport) removeIdleConn(pconn *persistConn) bool { t.idleMu.Lock() defer t.idleMu.Unlock() - t.removeIdleConnLocked(pconn) + return t.removeIdleConnLocked(pconn) } // t.idleMu must be held. -func (t *Transport) removeIdleConnLocked(pconn *persistConn) { +func (t *Transport) removeIdleConnLocked(pconn *persistConn) bool { if pconn.idleTimer != nil { pconn.idleTimer.Stop() } t.idleLRU.remove(pconn) key := pconn.cacheKey pconns := t.idleConn[key] + var removed bool switch len(pconns) { case 0: // Nothing case 1: if pconns[0] == pconn { delete(t.idleConn, key) + removed = true } default: for i, v := range pconns { @@ -996,9 +999,11 @@ func (t *Transport) removeIdleConnLocked(pconn *persistConn) { // conns at the end. copy(pconns[i:], pconns[i+1:]) t.idleConn[key] = pconns[:len(pconns)-1] + removed = true break } } + return removed } func (t *Transport) setReqCanceler(r *Request, fn func(error)) { diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index d0b12b3cb0..9f31e83e31 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -5832,3 +5832,59 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) { t.Errorf("GotConn calls = %v; want %v", got, want) } } + +// Issue 34941 +// When the client has too many concurrent requests on a single connection, +// http.http2noCachedConnError is reported on multiple requests. There should +// only be one decrement regardless of the number of failures. +func TestTransportDecrementConnWhenIdleConnRemoved(t *testing.T) { + defer afterTest(t) + + h := HandlerFunc(func(w ResponseWriter, r *Request) { + _, err := w.Write([]byte("foo")) + if err != nil { + t.Fatalf("Write: %v", err) + } + }) + + ts := httptest.NewUnstartedServer(h) + ts.TLS = &tls.Config{NextProtos: []string{"h2"}} + ts.StartTLS() + defer ts.Close() + + c := ts.Client() + tr := c.Transport.(*Transport) + tr.MaxConnsPerHost = 1 + if err := ExportHttp2ConfigureTransport(tr); err != nil { + t.Fatalf("ExportHttp2ConfigureTransport: %v", err) + } + + errCh := make(chan error, 300) + doReq := func() { + resp, err := c.Get(ts.URL) + if err != nil { + errCh <- fmt.Errorf("request failed: %v", err) + return + } + defer resp.Body.Close() + _, err = ioutil.ReadAll(resp.Body) + if err != nil { + errCh <- fmt.Errorf("read body failed: %v", err) + } + } + + var wg sync.WaitGroup + for i := 0; i < 300; i++ { + wg.Add(1) + go func() { + defer wg.Done() + doReq() + }() + } + wg.Wait() + close(errCh) + + for err := range errCh { + t.Errorf("error occurred: %v", err) + } +} -- cgit v1.2.3-54-g00ecf From a7acf9af07bdc288129fa5756768b41f312d05f4 Mon Sep 17 00:00:00 2001 From: Alexander Rakoczy Date: Wed, 12 Feb 2020 13:08:48 -0500 Subject: [release-branch.go1.13] go1.13.8 Change-Id: Ia174ccd8d5c26f44aeea188113e292f5048ec873 Reviewed-on: https://go-review.googlesource.com/c/go/+/219219 Run-TryBot: Alexander Rakoczy TryBot-Result: Gobot Gobot Reviewed-by: Carlos Amedee --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ab1e52b611..70023c4bd4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -go1.13.7 \ No newline at end of file +go1.13.8 \ No newline at end of file -- cgit v1.2.3-54-g00ecf