fix: memory leak issue with diff protocol (#1019)

This commit is contained in:
dylanhuang 2022-07-26 16:33:59 +08:00 committed by GitHub
parent cd46de9e0b
commit dd3b3a69b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

@ -509,6 +509,7 @@ func (h *handler) runDiffExtension(peer *diff.Peer, handler diff.Handler) error
if err := h.peers.registerDiffExtension(peer); err != nil {
peer.Log().Error("Diff extension registration failed", "err", err)
peer.Close()
return err
}
return handler(peer)

@ -45,6 +45,7 @@ func (h *diffHandler) RunPeer(peer *diff.Peer, hand diff.Handler) error {
wait <- peer
}
ps.lock.Unlock()
peer.Close()
return err
}
return (*handler)(h).runDiffExtension(peer, hand)