]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix race in webtorrent.TrackerClient.Run
authorMatt Joiner <anacrolix@gmail.com>
Mon, 1 Jun 2020 01:11:41 +0000 (11:11 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 1 Jun 2020 01:11:41 +0000 (11:11 +1000)
webtorrent/tracker_client.go

index 39a7e347b00e715f49c4b2986bf4cffb758efddb..5af6c7c0df74a522614f47b949d629a749c707c3 100644 (file)
@@ -92,9 +92,11 @@ func (tc *TrackerClient) Run() error {
                tc.mu.Unlock()
                err := tc.doWebsocket()
                level := log.Info
+               tc.mu.Lock()
                if tc.closed {
                        level = log.Debug
                }
+               tc.mu.Unlock()
                tc.Logger.WithDefaultLevel(level).Printf("websocket instance ended: %v", err)
                time.Sleep(time.Minute)
                tc.mu.Lock()