mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 22:49:13 +08:00
fix(bitswap): release the lock last
The area above the lock was getting big. Moving this up to avoid mistakes down the road.
This commit is contained in:
@ -160,6 +160,9 @@ func (e *Engine) Peers() []peer.ID {
|
||||
// MessageReceived performs book-keeping. Returns error if passed invalid
|
||||
// arguments.
|
||||
func (e *Engine) MessageReceived(p peer.ID, m bsmsg.BitSwapMessage) error {
|
||||
e.lock.Lock()
|
||||
defer e.lock.Unlock()
|
||||
|
||||
log := log.Prefix("bitswap.Engine.MessageReceived(%s)", p)
|
||||
log.Debugf("enter. %d entries %d blocks", len(m.Wantlist()), len(m.Blocks()))
|
||||
defer log.Debugf("exit")
|
||||
@ -175,9 +178,6 @@ func (e *Engine) MessageReceived(p peer.ID, m bsmsg.BitSwapMessage) error {
|
||||
}
|
||||
}()
|
||||
|
||||
e.lock.Lock()
|
||||
defer e.lock.Unlock()
|
||||
|
||||
l := e.findOrCreate(p)
|
||||
if m.Full() {
|
||||
l.wantList = wl.New()
|
||||
|
Reference in New Issue
Block a user