mirror of
https://github.com/golang/go
synced 2024-11-25 10:07:56 -07:00
http: close connection after printing panic stack trace
In a testing situation, it's possible for a local http server to panic and the test exit without the stack trace ever being printed. Fixes #2480. R=rsc, bradfitz CC=golang-dev https://golang.org/cl/5414048
This commit is contained in:
parent
19d064f68a
commit
516168057e
@ -569,14 +569,14 @@ func (c *conn) serve() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.rwc != nil { // may be nil if connection hijacked
|
|
||||||
c.rwc.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
fmt.Fprintf(&buf, "http: panic serving %v: %v\n", c.remoteAddr, err)
|
fmt.Fprintf(&buf, "http: panic serving %v: %v\n", c.remoteAddr, err)
|
||||||
buf.Write(debug.Stack())
|
buf.Write(debug.Stack())
|
||||||
log.Print(buf.String())
|
log.Print(buf.String())
|
||||||
|
|
||||||
|
if c.rwc != nil { // may be nil if connection hijacked
|
||||||
|
c.rwc.Close()
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if tlsConn, ok := c.rwc.(*tls.Conn); ok {
|
if tlsConn, ok := c.rwc.(*tls.Conn); ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user