Browse Source

Make env var DEBUG_HTTP2_GOROUTINES control goroutine tracking.

Also, add a fast path to newGoroutineLock when tracking
isn't enabled.
Brad Fitzpatrick 10 years ago
parent
commit
6d53d221a9
1 changed files with 5 additions and 1 deletions
  1. 5 1
      gotrack.go

+ 5 - 1
gotrack.go

@@ -14,16 +14,20 @@ import (
 	"bytes"
 	"errors"
 	"fmt"
+	"os"
 	"runtime"
 	"strconv"
 	"sync"
 )
 
-var DebugGoroutines = false
+var DebugGoroutines = os.Getenv("DEBUG_HTTP2_GOROUTINES") == "1"
 
 type goroutineLock uint64
 
 func newGoroutineLock() goroutineLock {
+	if !DebugGoroutines {
+		return 0
+	}
 	return goroutineLock(curGoroutineID())
 }