]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix race in ExportStatusWriter
authorMatt Joiner <anacrolix@gmail.com>
Fri, 19 Jan 2024 05:35:36 +0000 (16:35 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 19 Jan 2024 05:37:11 +0000 (16:37 +1100)
internal/testutil/status_writer.go

index ac872d57c04725556e1b4e758aa27a09dcddbb52..bcc5c2b5d6b00ebc4f40c34514f94bd50d24cba9 100644 (file)
@@ -40,7 +40,9 @@ func ExportStatusWriter(sw StatusWriter, path string, t testing.TB) (release fun
        http.HandleFunc(
                pattern,
                func(w http.ResponseWriter, r *http.Request) {
+                       mu.Lock()
                        sw := sws[pattern]
+                       mu.Unlock()
                        if sw == nil {
                                http.NotFound(w, r)
                                return