fix: skip check DisableAutoBackSource option when scheduler says back source (#693)

Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
Jim Ma 2021-09-28 17:25:18 +08:00 committed by Gaius
parent 6343c8bdaf
commit fc7eec17bf
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 10 additions and 24 deletions

View File

@ -505,18 +505,11 @@ func (pt *peerTask) waitFirstPeerPacket() bool {
time.Now().Sub(pt.callback.GetStartTime()).Microseconds(), pt.peerPacket.Load().(*scheduler.PeerPacket).MainPeer) time.Now().Sub(pt.callback.GetStartTime()).Microseconds(), pt.peerPacket.Load().(*scheduler.PeerPacket).MainPeer)
return true return true
} }
// when schedule timeout, receivePeerPacket will close pt.peerPacketReady // when scheduler says dfcodes.SchedNeedBackSource, receivePeerPacket will close pt.peerPacketReady
if pt.schedulerOption.DisableAutoBackSource { pt.Infof("start download from source due to dfcodes.SchedNeedBackSource")
pt.failedReason = reasonBackSourceDisabled pt.span.AddEvent("back source due to scheduler says need back source")
err := fmt.Errorf("%s, auto back source disabled", pt.failedReason) pt.needBackSource = true
pt.span.RecordError(err) pt.backSource()
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()
}
case <-time.After(pt.schedulerOption.ScheduleTimeout.Duration): case <-time.After(pt.schedulerOption.ScheduleTimeout.Duration):
if pt.schedulerOption.DisableAutoBackSource { if pt.schedulerOption.DisableAutoBackSource {
pt.failedReason = reasonScheduleTimeout pt.failedReason = reasonScheduleTimeout
@ -555,18 +548,11 @@ func (pt *peerTask) waitAvailablePeerPacket() (int32, bool) {
// research from piece 0 // research from piece 0
return pt.getNextPieceNum(0), true return pt.getNextPieceNum(0), true
} }
// when schedule timeout, receivePeerPacket will close pt.peerPacketReady // when scheduler says dfcodes.SchedNeedBackSource, receivePeerPacket will close pt.peerPacketReady
if pt.schedulerOption.DisableAutoBackSource { pt.Infof("start download from source due to dfcodes.SchedNeedBackSource")
pt.failedReason = reasonBackSourceDisabled pt.span.AddEvent("back source due to scheduler says need back source ")
err := fmt.Errorf("%s, auto back source disabled", pt.failedReason) pt.needBackSource = true
pt.span.RecordError(err) pt.backSource()
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()
}
case <-time.After(pt.schedulerOption.ScheduleTimeout.Duration): case <-time.After(pt.schedulerOption.ScheduleTimeout.Duration):
if pt.schedulerOption.DisableAutoBackSource { if pt.schedulerOption.DisableAutoBackSource {
pt.failedReason = reasonReScheduleTimeout pt.failedReason = reasonReScheduleTimeout