diff --git a/dht/dht.go b/dht/dht.go index 01d28352..3f437730 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -629,7 +629,10 @@ func (s *Server) serve() error { logonce.Stderr.Printf("received dht packet exceeds buffer size") continue } - if s.ipBlocked(util.AddrIP(addr)) { + s.mu.Lock() + blocked := s.ipBlocked(util.AddrIP(addr)) + s.mu.Unlock() + if blocked { continue } s.processPacket(b[:n], newDHTAddr(addr)) diff --git a/file.go b/file.go index 2efbaeaa..688fc2fa 100644 --- a/file.go +++ b/file.go @@ -35,6 +35,8 @@ type FilePieceState struct { // Returns the state of pieces in this file. func (f *File) State() (ret []FilePieceState) { + f.t.cl.mu.Lock() + defer f.t.cl.mu.Unlock() pieceSize := int64(f.t.usualPieceSize()) off := f.offset % pieceSize remaining := f.length