summaryrefslogtreecommitdiff
path: root/src/pkg/http/pprof
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-05-04 01:04:51 +0200
committerOndřej Surý <ondrej@sury.org>2011-05-04 01:04:51 +0200
commit14cda8f405d55947c0a3fae0852b04af8405eae0 (patch)
treefa304ad78ef1a8166b3dcd964e1a63091d4c9db2 /src/pkg/http/pprof
parentc1ba1a0fec4aed430709030f98a3bdb90bfeea16 (diff)
downloadgolang-upstream/57.tar.gz
Imported Upstream version 57upstream/57
Diffstat (limited to 'src/pkg/http/pprof')
-rw-r--r--src/pkg/http/pprof/pprof.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/pkg/http/pprof/pprof.go b/src/pkg/http/pprof/pprof.go
index bc79e2183..917c7f877 100644
--- a/src/pkg/http/pprof/pprof.go
+++ b/src/pkg/http/pprof/pprof.go
@@ -26,6 +26,7 @@ package pprof
import (
"bufio"
+ "bytes"
"fmt"
"http"
"os"
@@ -88,10 +89,14 @@ func Profile(w http.ResponseWriter, r *http.Request) {
func Symbol(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+ // We have to read the whole POST body before
+ // writing any output. Buffer the output here.
+ var buf bytes.Buffer
+
// We don't know how many symbols we have, but we
// do have symbol information. Pprof only cares whether
// this number is 0 (no symbols available) or > 0.
- fmt.Fprintf(w, "num_symbols: 1\n")
+ fmt.Fprintf(&buf, "num_symbols: 1\n")
var b *bufio.Reader
if r.Method == "POST" {
@@ -109,14 +114,19 @@ func Symbol(w http.ResponseWriter, r *http.Request) {
if pc != 0 {
f := runtime.FuncForPC(uintptr(pc))
if f != nil {
- fmt.Fprintf(w, "%#x %s\n", pc, f.Name())
+ fmt.Fprintf(&buf, "%#x %s\n", pc, f.Name())
}
}
// Wait until here to check for err; the last
// symbol will have an err because it doesn't end in +.
if err != nil {
+ if err != os.EOF {
+ fmt.Fprintf(&buf, "reading request: %v\n", err)
+ }
break
}
}
+
+ w.Write(buf.Bytes())
}