Browse Source

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

dylanhuang 3 năm trước cách đây
mục cha
commit
9acfab4dc4
2 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 1 0
      eth/handler.go
  2. 1 0
      eth/handler_diff.go

+ 1 - 0
eth/handler.go

@@ -390,6 +390,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)

+ 1 - 0
eth/handler_diff.go

@@ -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)