Since that method uses 'mux.m', we need to lock the mutex to avoid data races.
Change-Id: I998448a6e482b5d6a1b24f3354bb824906e23172
GitHub-Last-Rev:
163a7d4942e793b328e05a7eb91f6d3fdc4ba12b
GitHub-Pull-Request: golang/go#23994
Reviewed-on: https://go-review.googlesource.com/96575
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
}
}
+func TestShouldRedirectConcurrency(t *testing.T) {
+ setParallel(t)
+ defer afterTest(t)
+
+ mux := NewServeMux()
+ ts := httptest.NewServer(mux)
+ defer ts.Close()
+ mux.HandleFunc("/", func(w ResponseWriter, r *Request) {})
+}
+
func BenchmarkServeMux(b *testing.B) {
type test struct {
// path+"/". This should happen if a handler is registered for path+"/" but
// not path -- see comments at ServeMux.
func (mux *ServeMux) shouldRedirect(host, path string) bool {
+ mux.mu.RLock()
+ defer mux.mu.RUnlock()
+
p := []string{path, host + path}
for _, c := range p {