dht/dht.go | 5 ++++- file.go | 2 ++ diff --git a/dht/dht.go b/dht/dht.go index 01d2835209a7c0221bbe421087042be1acce1c72..3f4377307f99dd17fa7d35c45039b1c64229b21d 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -629,7 +629,10 @@ if n == len(b) { 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 2efbaeaaf8d0149e1e0b865492d1f1470a763a8f..688fc2faa92ae6af221d706a94fe4d27461f5eb2 100644 --- a/file.go +++ b/file.go @@ -35,6 +35,8 @@ } // 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