les: fix invalid delivery handling in retriever (#17727)

This commit is contained in:
Felföldi Zsolt 2018-09-21 09:59:21 +02:00 committed by Péter Szilágyi
parent 32c05e82a3
commit ab13cd9924
1 changed files with 8 additions and 1 deletions

View File

@ -212,11 +212,18 @@ func (r *sentReq) stateRequesting() reqStateFn {
// no need to go to stopped state because waiting() already returned false
return nil
}
case rpSoftTimeout, rpDeliveredInvalid:
case rpSoftTimeout:
// last request timed out, try asking a new peer
go r.tryRequest()
r.lastReqQueued = true
return r.stateRequesting
case rpDeliveredInvalid:
// if it was the last sent request (set to nil by update) then start a new one
if !r.lastReqQueued && r.lastReqSentTo == nil {
go r.tryRequest()
r.lastReqQueued = true
}
return r.stateRequesting
case rpDeliveredValid:
r.stop(nil)
return r.stateStopped