Commit 51616805 authored by Roger Peppe's avatar Roger Peppe Committed by Russ Cox

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
parent 19d064f6
......@@ -569,14 +569,14 @@ func (c *conn) serve() {
if err == nil {
return
}
if c.rwc != nil { // may be nil if connection hijacked
c.rwc.Close()
}
var buf bytes.Buffer
fmt.Fprintf(&buf, "http: panic serving %v: %v\n", c.remoteAddr, err)
buf.Write(debug.Stack())
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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment