git » go-net » commit 57bfaa8

http2: add more Transport logging around why connections close

author Brad Fitzpatrick
2016-08-03 15:39:36 UTC
committer Brad Fitzpatrick
2016-08-03 15:59:20 UTC
parent e2ba55e4e78399d85f2a0e0b92396b81ed410633

http2: add more Transport logging around why connections close

For debugging golang/go#16514

Change-Id: I8aa5706eef4e9b4104cab391172b8919601ebf3a
Reviewed-on: https://go-review.googlesource.com/25440
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>

http2/transport.go +12 -5

diff --git a/http2/transport.go b/http2/transport.go
index 149dcca..64ec4e7 100644
--- a/http2/transport.go
+++ b/http2/transport.go
@@ -414,10 +414,6 @@ func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
 }
 
 func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) {
-	if VerboseLogs {
-		t.vlogf("http2: Transport creating client conn to %v", c.RemoteAddr())
-	}
-
 	cc := &ClientConn{
 		t:                    t,
 		tconn:                c,
@@ -430,6 +426,9 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
 		singleUse:            singleUse,
 		wantSettingsAck:      true,
 	}
+	if VerboseLogs {
+		t.vlogf("http2: Transport creating client conn %#x to %v", cc, c.RemoteAddr())
+	}
 	cc.cond = sync.NewCond(&cc.mu)
 	cc.flow.add(int32(initialWindowSize))
 
@@ -509,9 +508,14 @@ func (cc *ClientConn) closeIfIdle() {
 		return
 	}
 	cc.closed = true
+	nextID := cc.nextStreamID
 	// TODO: do clients send GOAWAY too? maybe? Just Close:
 	cc.mu.Unlock()
 
+	if VerboseLogs {
+		cc.vlogf("http2: Transport closing idle conn %#x (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, nextID-2)
+	}
+
 	cc.tconn.Close()
 }
 
@@ -1225,7 +1229,7 @@ func (rl *clientConnReadLoop) run() error {
 	for {
 		f, err := cc.fr.ReadFrame()
 		if err != nil {
-			cc.vlogf("Transport readFrame error: (%T) %v", err, err)
+			cc.vlogf("http2: Transport readFrame error on conn %#x: (%T) %v", cc, err, err)
 		}
 		if se, ok := err.(StreamError); ok {
 			if cs := cc.streamByID(se.StreamID, true /*ended; remove it*/); cs != nil {
@@ -1277,6 +1281,9 @@ func (rl *clientConnReadLoop) run() error {
 			cc.logf("Transport: unhandled response frame type %T", f)
 		}
 		if err != nil {
+			if VerboseLogs {
+				cc.vlogf("http2: Transport conn %#x received error from processing frame %v: %v", cc, summarizeFrame(f), err)
+			}
 			return err
 		}
 		if rl.closeWhenIdle && gotReply && maybeIdle && len(rl.activeRes) == 0 {