Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(88)

Delta Between Two Patch Sets: src/pkg/net/http/server.go

Issue 6971049: code review 6971049: net/http: fix server connection leak on Handler's panic(nil) (Closed)
Left Patch Set: Created 11 years, 3 months ago
Right Patch Set: diff -r 0c135754c93a https://go.googlecode.com/hg/ Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/http/serve_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // HTTP server. See RFC 2616. 5 // HTTP server. See RFC 2616.
6 6
7 // TODO(rsc): 7 // TODO(rsc):
8 // logging 8 // logging
9 9
10 package http 10 package http
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 709
710 const size = 4096 710 const size = 4096
711 buf := make([]byte, size) 711 buf := make([]byte, size)
712 buf = buf[:runtime.Stack(buf, false)] 712 buf = buf[:runtime.Stack(buf, false)]
713 log.Printf("http: panic serving %v: %v\n%s", c.remoteAddr, err, buf) 713 log.Printf("http: panic serving %v: %v\n%s", c.remoteAddr, err, buf)
714 714
715 if c.rwc != nil { // may be nil if connection hijacked 715 if c.rwc != nil { // may be nil if connection hijacked
716 c.rwc.Close() 716 c.rwc.Close()
717 } 717 }
718 }() 718 }()
719 defer c.close()
719 720
720 if tlsConn, ok := c.rwc.(*tls.Conn); ok { 721 if tlsConn, ok := c.rwc.(*tls.Conn); ok {
721 if err := tlsConn.Handshake(); err != nil { 722 if err := tlsConn.Handshake(); err != nil {
722 c.close() 723 c.close()
723 return 724 return
724 } 725 }
725 c.tlsState = new(tls.ConnectionState) 726 c.tlsState = new(tls.ConnectionState)
726 *c.tlsState = tlsConn.ConnectionState() 727 *c.tlsState = tlsConn.ConnectionState()
727 } 728 }
728 729
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 return 785 return
785 } 786 }
786 w.finishRequest() 787 w.finishRequest()
787 if w.closeAfterReply { 788 if w.closeAfterReply {
788 if w.requestBodyLimitHit { 789 if w.requestBodyLimitHit {
789 c.closeWriteAndWait() 790 c.closeWriteAndWait()
790 } 791 }
791 break 792 break
792 } 793 }
793 } 794 }
794 c.close()
795 } 795 }
796 796
797 func (w *response) sendExpectationFailed() { 797 func (w *response) sendExpectationFailed() {
798 // TODO(bradfitz): let ServeHTTP handlers handle 798 // TODO(bradfitz): let ServeHTTP handlers handle
799 // requests with non-standard expectation[s]? Seems 799 // requests with non-standard expectation[s]? Seems
800 // theoretical at best, and doesn't fit into the 800 // theoretical at best, and doesn't fit into the
801 // current ServeHTTP model anyway. We'd need to 801 // current ServeHTTP model anyway. We'd need to
802 // make the ResponseWriter an optional 802 // make the ResponseWriter an optional
803 // "ExpectReplier" interface or something. 803 // "ExpectReplier" interface or something.
804 // 804 //
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 log.Printf("%s.Read(%d) = %d, %v", c.name, len(p), n, err) 1466 log.Printf("%s.Read(%d) = %d, %v", c.name, len(p), n, err)
1467 return 1467 return
1468 } 1468 }
1469 1469
1470 func (c *loggingConn) Close() (err error) { 1470 func (c *loggingConn) Close() (err error) {
1471 log.Printf("%s.Close() = ...", c.name) 1471 log.Printf("%s.Close() = ...", c.name)
1472 err = c.Conn.Close() 1472 err = c.Conn.Close()
1473 log.Printf("%s.Close() = %v", c.name, err) 1473 log.Printf("%s.Close() = %v", c.name, err)
1474 return 1474 return
1475 } 1475 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b