Skip to content

Commit

Permalink
fix: skip check DisableAutoBackSource option when scheduler says back…
Browse files Browse the repository at this point in the history
… source (#693)

Signed-off-by: Jim Ma <[email protected]>
  • Loading branch information
jim3ma authored Sep 28, 2021
1 parent 89b42c4 commit 7dbb9ee
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions client/daemon/peer/peertask_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,18 +505,11 @@ func (pt *peerTask) waitFirstPeerPacket() bool {
time.Now().Sub(pt.callback.GetStartTime()).Microseconds(), pt.peerPacket.Load().(*scheduler.PeerPacket).MainPeer)
return true
}
// when schedule timeout, receivePeerPacket will close pt.peerPacketReady
if pt.schedulerOption.DisableAutoBackSource {
pt.failedReason = reasonBackSourceDisabled
err := fmt.Errorf("%s, auto back source disabled", pt.failedReason)
pt.span.RecordError(err)
pt.Errorf(err.Error())
} else {
pt.Warnf("start download from source due to dfcodes.SchedNeedBackSource")
pt.span.AddEvent("back source due to scheduler says need back source")
pt.needBackSource = true
pt.backSource()
}
// when scheduler says dfcodes.SchedNeedBackSource, receivePeerPacket will close pt.peerPacketReady
pt.Infof("start download from source due to dfcodes.SchedNeedBackSource")
pt.span.AddEvent("back source due to scheduler says need back source")
pt.needBackSource = true
pt.backSource()
case <-time.After(pt.schedulerOption.ScheduleTimeout.Duration):
if pt.schedulerOption.DisableAutoBackSource {
pt.failedReason = reasonScheduleTimeout
Expand Down Expand Up @@ -555,18 +548,11 @@ func (pt *peerTask) waitAvailablePeerPacket() (int32, bool) {
// research from piece 0
return pt.getNextPieceNum(0), true
}
// when schedule timeout, receivePeerPacket will close pt.peerPacketReady
if pt.schedulerOption.DisableAutoBackSource {
pt.failedReason = reasonBackSourceDisabled
err := fmt.Errorf("%s, auto back source disabled", pt.failedReason)
pt.span.RecordError(err)
pt.Errorf(err.Error())
} else {
pt.Warnf("start download from source due to dfcodes.SchedNeedBackSource")
pt.span.AddEvent("back source due to scheduler says need back source ")
pt.needBackSource = true
pt.backSource()
}
// when scheduler says dfcodes.SchedNeedBackSource, receivePeerPacket will close pt.peerPacketReady
pt.Infof("start download from source due to dfcodes.SchedNeedBackSource")
pt.span.AddEvent("back source due to scheduler says need back source ")
pt.needBackSource = true
pt.backSource()
case <-time.After(pt.schedulerOption.ScheduleTimeout.Duration):
if pt.schedulerOption.DisableAutoBackSource {
pt.failedReason = reasonReScheduleTimeout
Expand Down

0 comments on commit 7dbb9ee

Please sign in to comment.