]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: gracefully handle empty profiles
authorDmitry Vyukov <dvyukov@google.com>
Thu, 18 Jun 2015 14:19:18 +0000 (16:19 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Thu, 18 Jun 2015 14:46:49 +0000 (14:46 +0000)
Return a meaningful message when a profile is empty.
Also rename "IO blocking" to "Network blocking",
currently only network blocking is captured.

Fixes #11098

Change-Id: Ib6f1292b8ade4805756fcb6696ba1fca8f9f39a9
Reviewed-on: https://go-review.googlesource.com/11243
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/trace/main.go
src/cmd/trace/pprof.go

index ea6eef353f19a083d1384cfc8203624c9177b981..c8a9231de7e0a5af6a3326fde0e8889b950f5429 100644 (file)
@@ -124,7 +124,7 @@ var templMain = []byte(`
 <body>
 <a href="/trace">View trace</a><br>
 <a href="/goroutines">Goroutine analysis</a><br>
-<a href="/io">IO blocking profile</a><br>
+<a href="/io">Network blocking profile</a><br>
 <a href="/block">Synchronization blocking profile</a><br>
 <a href="/syscall">Syscall blocking profile</a><br>
 <a href="/sched">Scheduler latency profile</a><br>
index 9e6f27797823fdd63c77bc5b77ddaba088765da3..154f04d56c568587c3ef8c6aa171310f50b03183 100644 (file)
@@ -124,6 +124,10 @@ func httpSched(w http.ResponseWriter, r *http.Request) {
 
 // generateSVGProfile generates pprof-like profile stored in prof and writes in to w.
 func serveSVGProfile(w http.ResponseWriter, r *http.Request, prof map[uint64]Record) {
+       if len(prof) == 0 {
+               http.Error(w, "The profile is empty", http.StatusNotFound)
+               return
+       }
        blockf, err := ioutil.TempFile("", "block")
        if err != nil {
                http.Error(w, fmt.Sprintf("failed to create temp file: %v", err), http.StatusInternalServerError)