mirror of
https://github.com/golang/go
synced 2024-11-23 17:00:07 -07:00
net/http: quiet http2 log spam
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>
This commit is contained in:
parent
2c12b81739
commit
aff6aa0a21
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user