]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: quiet http2 log spam
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 26 Jan 2016 20:33:21 +0000 (20:33 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 26 Jan 2016 21:04:27 +0000 (21:04 +0000)
Updates x/net/http2 to git rev eb066e3 for https://golang.org/cl/18932

Fixes #13925
Fixes #14061

Change-Id: I73f8c09232877404362358240b7b369bb9c76a12
Reviewed-on: https://go-review.googlesource.com/18934
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/h2_bundle.go

index 21106419559a13340b0fdcc46a7b296d2cea6b95..e7236299e2253d824739005e97a8b52043a5107e 100644 (file)
@@ -32,6 +32,7 @@ import (
        "net/textproto"
        "net/url"
        "os"
+       "reflect"
        "runtime"
        "sort"
        "strconv"
@@ -2850,12 +2851,50 @@ func (sc *http2serverConn) logf(format string, args ...interface{}) {
        }
 }
 
+var http2uintptrType = reflect.TypeOf(uintptr(0))
+
+// errno returns v's underlying uintptr, else 0.
+//
+// TODO: remove this helper function once http2 can use build
+// tags. See comment in isClosedConnError.
+func http2errno(v error) uintptr {
+       if rv := reflect.ValueOf(v); rv.Kind() == reflect.Uintptr {
+               return uintptr(rv.Uint())
+       }
+       return 0
+}
+
+// isClosedConnError reports whether err is an error from use of a closed
+// network connection.
+func http2isClosedConnError(err error) bool {
+       if err == nil {
+               return false
+       }
+
+       str := err.Error()
+       if strings.Contains(str, "use of closed network connection") {
+               return true
+       }
+
+       if runtime.GOOS == "windows" {
+               if oe, ok := err.(*net.OpError); ok && oe.Op == "read" {
+                       if se, ok := oe.Err.(*os.SyscallError); ok && se.Syscall == "wsarecv" {
+                               const WSAECONNABORTED = 10053
+                               const WSAECONNRESET = 10054
+                               if n := http2errno(se.Err); n == WSAECONNRESET || n == WSAECONNABORTED {
+                                       return true
+                               }
+                       }
+               }
+       }
+       return false
+}
+
 func (sc *http2serverConn) condlogf(err error, format string, args ...interface{}) {
        if err == nil {
                return
        }
-       str := err.Error()
-       if err == io.EOF || strings.Contains(str, "use of closed network connection") {
+       if err == io.EOF || err == io.ErrUnexpectedEOF || http2isClosedConnError(err) {
 
                sc.vlogf(format, args...)
        } else {
@@ -3372,7 +3411,7 @@ func (sc *http2serverConn) processFrameFromReader(res http2readFrameResult) bool
                        sc.goAway(http2ErrCodeFrameSize)
                        return true
                }
-               clientGone := err == io.EOF || strings.Contains(err.Error(), "use of closed network connection")
+               clientGone := err == io.EOF || err == io.ErrUnexpectedEOF || http2isClosedConnError(err)
                if clientGone {
 
                        return false
@@ -3401,7 +3440,7 @@ func (sc *http2serverConn) processFrameFromReader(res http2readFrameResult) bool
                return true
        default:
                if res.err != nil {
-                       sc.logf("http2: server closing client connection; error reading frame from client %s: %v", sc.conn.RemoteAddr(), err)
+                       sc.vlogf("http2: server closing client connection; error reading frame from client %s: %v", sc.conn.RemoteAddr(), err)
                } else {
                        sc.logf("http2: server closing client connection: %v", err)
                }