fix: scheduler success event (#891)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2021-12-08 10:33:56 +08:00
parent dc50bd31d5
commit 04a3550925
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 21 additions and 20 deletions

View File

@ -175,7 +175,11 @@ func (e peerDownloadPieceSuccessEvent) apply(s *state) {
var candidates []*supervisor.Peer
parentPeer, ok := s.peerManager.Get(e.pr.DstPid)
if ok {
if !ok {
e.peer.Log().Warnf("parent peer %s not found", e.pr.DstPid)
return
}
if parentPeer.IsLeave() {
e.peer.Log().Warnf("peerDownloadPieceSuccessEvent: need reschedule parent for peer because it's parent is already left")
e.peer.ReplaceParent(nil)
@ -194,9 +198,6 @@ func (e peerDownloadPieceSuccessEvent) apply(s *state) {
e.pr.DstPid)
e.peer.ReplaceParent(parentPeer)
}
} else {
e.peer.Log().Warnf("parent peer %s not found", e.pr.DstPid)
}
parentPeer.Touch()
if parentPeer.ID == e.pr.DstPid {