Do not ignore errors in reserve_next_needed_piece()
This commit is contained in:
parent
8cdf44c4fd
commit
dfdb6b5fae
1 changed files with 8 additions and 3 deletions
|
|
@ -1011,10 +1011,15 @@ impl PeerHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let n_opt = match n_opt {
|
||||||
|
Some(n_opt) => n_opt,
|
||||||
|
None => return Ok(None),
|
||||||
|
};
|
||||||
|
|
||||||
self.state
|
self.state
|
||||||
.lengths
|
.lengths
|
||||||
.validate_piece_index(n_opt.context("invalid n_opt")? as u32)
|
.validate_piece_index(n_opt as u32)
|
||||||
.context("invalid piece")?
|
.context("bug: invalid piece")?
|
||||||
};
|
};
|
||||||
g.inflight_pieces.insert(
|
g.inflight_pieces.insert(
|
||||||
n,
|
n,
|
||||||
|
|
@ -1214,7 +1219,7 @@ impl PeerHandler {
|
||||||
// Afterwards means we are close to completion, try stealing more aggressively.
|
// Afterwards means we are close to completion, try stealing more aggressively.
|
||||||
let next = match self
|
let next = match self
|
||||||
.try_steal_old_slow_piece(10.)
|
.try_steal_old_slow_piece(10.)
|
||||||
.or_else(|| self.reserve_next_needed_piece().ok().flatten())
|
.map_or_else(|| self.reserve_next_needed_piece(), |v| Ok(Some(v)))?
|
||||||
.or_else(|| self.try_steal_old_slow_piece(3.))
|
.or_else(|| self.try_steal_old_slow_piece(3.))
|
||||||
{
|
{
|
||||||
Some(next) => next,
|
Some(next) => next,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue