$ git log | head -n 1
commit 90a68935733ef37d41cb520ffeb56f196a356811
$ ./13667.sh
2015/12/17 18:50:12 done here &{GET http://127.0.0.1:19870/ HTTP/1.1 1 1 map[] <nil> 0 [] false 127.0.0.1:19870 map[] map[] <nil> map[] <nil> <nil>}
2015/12/17 18:50:12 cm, err {<nil> http 127.0.0.1:19870} <nil> true
2015/12/17 18:50:12 pconn, err &{<nil> 0xc8200bc210 { http 127.0.0.1:19870} 0xc820028028 <nil> 0xc82005e660 false 0xc820010500 0xc82005e4e0 0xc82005e540 0xc82005e5a0 false 0xc82005e600 {0 0} 0 false false false false <nil>} <nil> true
EOF
$ ./13667.sh
2015/12/17 18:50:41 done here &{GET http://127.0.0.1:19870/ HTTP/1.1 1 1 map[] <nil> 0 [] false 127.0.0.1:19870 map[] map[] <nil> map[] <nil> <nil>}
2015/12/17 18:50:41 cm, err {<nil> http 127.0.0.1:19870} <nil> true
2015/12/17 18:50:41 pconn, err &{<nil> 0xc8200bc210 { http 127.0.0.1:19870} 0xc820028028 <nil> 0xc82005e660 false 0xc820010500 0xc82005e4e0 0xc82005e540 0xc82005e5a0 false 0xc82005e600 {0 0} 0 false false false false <nil>} <nil> true
EOF
$ ./13667.sh
2015/12/17 18:52:11 done here &{GET http://127.0.0.1:19870/ HTTP/1.1 1 1 map[] <nil> 0 [] false 127.0.0.1:19870 map[] map[] <nil> map[] <nil> <nil>}
2015/12/17 18:52:11 cm, err {<nil> http 127.0.0.1:19870} <nil> true
2015/12/17 18:52:11 pconn, err &{<nil> 0xc8200bc210 { http 127.0.0.1:19870} 0xc820028028 <nil> 0xc82005e660 false 0xc820010500 0xc82005e4e0 0xc82005e540 0xc82005e5a0 false 0xc82005e600 {0 0} 0 false false false false <nil>} <nil> true
2015/12/17 18:52:11 checkTransportResend net/http: transport closed before response was received false
net/http: transport closed before response was received
$ ./13667.sh
2015/12/17 18:52:18 done here &{GET http://127.0.0.1:19870/ HTTP/1.1 1 1 map[] <nil> 0 [] false 127.0.0.1:19870 map[] map[] <nil> map[] <nil> <nil>}
2015/12/17 18:52:18 cm, err {<nil> http 127.0.0.1:19870} <nil> true
2015/12/17 18:52:18 pconn, err &{<nil> 0xc8200bc210 { http 127.0.0.1:19870} 0xc820028028 <nil> 0xc82005e660 false 0xc820010500 0xc82005e4e0 0xc82005e540 0xc82005e5a0 false 0xc82005e600 {0 0} 0 false false false false <nil>} <nil> true
2015/12/17 18:52:18 checkTransportResend net/http: transport closed before response was received false
net/http: transport closed before response was received
$
$ ./13667.sh
2015/12/17 18:52:39 done here &{GET http://127.0.0.1:19870/ HTTP/1.1 1 1 map[] <nil> 0 [] false 127.0.0.1:19870 map[] map[] <nil> map[] <nil> <nil>}
2015/12/17 18:52:39 cm, err {<nil> http 127.0.0.1:19870} <nil> true
2015/12/17 18:52:39 pconn, err &{<nil> 0xc8200bc210 { http 127.0.0.1:19870} 0xc820028028 <nil> 0xc82005e660 false 0xc820010500 0xc82005e4e0 0xc82005e540 0xc82005e5a0 false 0xc82005e600 {0 0} 0 false false false false <nil>} <nil> true
2015/12/17 18:52:39 checkTransportResend EOF false
2015/12/17 18:52:39 checkTransportResend EOF false
EOF
$ ./13667.sh
2015/12/17 18:52:52 done here &{GET http://127.0.0.1:19870/ HTTP/1.1 1 1 map[] <nil> 0 [] false 127.0.0.1:19870 map[] map[] <nil> map[] <nil> <nil>}
2015/12/17 18:52:52 cm, err {<nil> http 127.0.0.1:19870} <nil> true
2015/12/17 18:52:52 pconn, err &{<nil> 0xc8200bc210 { http 127.0.0.1:19870} 0xc820028028 <nil> 0xc82005e660 false 0xc820010500 0xc82005e4e0 0xc82005e540 0xc82005e5a0 false 0xc82005e600 {0 0} 0 false false false false <nil>} <nil> true
2015/12/17 18:52:52 checkTransportResend EOF false
2015/12/17 18:52:52 checkTransportResend EOF false
EOF
golang-13667-investigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"net/http" | |
) | |
func main() { | |
dialer := &net.Dialer{} | |
transport := &http.Transport{ | |
Dial: dialer.Dial, | |
} | |
request, _ := http.NewRequest("GET", "http://127.0.0.1:19870/", nil) | |
_, err := transport.RoundTrip(request) | |
fmt.Println(err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "net" | |
func main() { | |
ln, _ := net.Listen("tcp", ":19870") | |
conn, _ := ln.Accept() | |
conn.Close() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
go run 13667-server.go & | |
go run 13667-client.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/net/http/request.go b/src/net/http/request.go | |
index d1793c7..9e1d96e 100644 | |
--- a/src/net/http/request.go | |
+++ b/src/net/http/request.go | |
@@ -1051,6 +1051,7 @@ func (r *Request) wantsClose() bool { | |
} | |
func (r *Request) closeBody() { | |
+ fmt.Println("body==nil?", r.Body, r.Body==nil) | |
if r.Body != nil { | |
r.Body.Close() | |
} | |
diff --git a/src/net/http/transport.go b/src/net/http/transport.go | |
index e610f97..1a31d1d 100644 | |
--- a/src/net/http/transport.go | |
+++ b/src/net/http/transport.go | |
@@ -225,6 +225,7 @@ func (tr *transportRequest) extraHeaders() Header { | |
// For higher-level HTTP client support (such as handling of cookies | |
// and redirects), see Get, Post, and the Client type. | |
func (t *Transport) RoundTrip(req *Request) (*Response, error) { | |
+ log.Println("done here", req) | |
t.nextProtoOnce.Do(t.onceSetNextProtoDefaults) | |
if req.URL == nil { | |
req.closeBody() | |
@@ -239,6 +240,7 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { | |
altRT := t.altProto[req.URL.Scheme] | |
t.altMu.RUnlock() | |
if altRT != nil { | |
+ log.Println("altRT is non-nil") | |
if resp, err := altRT.RoundTrip(req); err != ErrSkipAltProtocol { | |
return resp, err | |
} | |
@@ -259,7 +261,9 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { | |
// treq gets modified by roundTrip, so we need to recreate for each retry. | |
treq := &transportRequest{Request: req} | |
cm, err := t.connectMethodForRequest(treq) | |
+ log.Println("cm, err", cm, err, err == nil) | |
if err != nil { | |
+ log.Println("closing here, err", err) | |
req.closeBody() | |
return nil, err | |
} | |
@@ -269,6 +273,7 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { | |
// pre-CONNECTed to https server. In any case, we'll be ready | |
// to send it requests. | |
pconn, err := t.getConn(req, cm) | |
+ log.Println("pconn, err", pconn, err, err == nil) | |
if err != nil { | |
t.setReqCanceler(req, nil) | |
req.closeBody() | |
@@ -299,6 +304,7 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { | |
// The return value is err or the unwrapped error inside a | |
// beforeRespHeaderError. | |
func checkTransportResend(err error, req *Request, pconn *persistConn) error { | |
+ log.Println("checkTransportResend", err, err == io.EOF) | |
brhErr, ok := err.(beforeRespHeaderError) | |
if !ok { | |
return err | |
@@ -1071,6 +1077,7 @@ func (pc *persistConn) readLoop() { | |
resp.Body.(*bodyEOFSignal).fn = func(err error) error { | |
isEOF := err == io.EOF | |
waitForBodyRead <- isEOF | |
+ log.Println("err encountered here", err) | |
if isEOF { | |
<-eofc // see comment above eofc declaration | |
} else if err != nil && pc.isCanceled() { | |
@@ -1515,6 +1522,7 @@ func (es *bodyEOFSignal) Close() error { | |
return nil | |
} | |
es.closed = true | |
+ log.Println("err encountered here", es.rerr) | |
if es.earlyCloseFn != nil && es.rerr != io.EOF { | |
return es.earlyCloseFn() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment