Skip to content

Commit

Permalink
Merge pull request #3142 from autonomys/fix-future-resumed-after-comp…
Browse files Browse the repository at this point in the history
…letion

Fix resuming future after completion
  • Loading branch information
nazar-pc authored Oct 17, 2024
2 parents 11d1762 + 20cf307 commit 8de49f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions crates/subspace-farmer/src/farmer_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,13 +1304,11 @@ where

// Drive above future and stream back any pieces that were downloaded so far
stream::poll_fn(move |cx| {
let end_result = fut.poll_unpin(cx);

if let Ok(maybe_result) = rx.try_next() {
if let Poll::Ready(maybe_result) = rx.poll_next_unpin(cx) {
return Poll::Ready(maybe_result);
}

end_result.map(|((), ())| None)
fut.poll_unpin(cx).map(|((), ())| None)
})
}

Expand Down
6 changes: 2 additions & 4 deletions crates/subspace-farmer/src/farmer_piece_getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,11 @@ where

// Drive above future and stream back any pieces that were downloaded so far
Ok(Box::new(stream::poll_fn(move |cx| {
let end_result = fut.poll_unpin(cx);

if let Ok(maybe_result) = rx.try_next() {
if let Poll::Ready(maybe_result) = rx.poll_next_unpin(cx) {
return Poll::Ready(maybe_result);
}

end_result.map(|()| None)
fut.poll_unpin(cx).map(|()| None)
})))
}
}
Expand Down
6 changes: 2 additions & 4 deletions crates/subspace-networking/src/utils/piece_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ where

// Drive above future and stream back any pieces that were downloaded so far
stream::poll_fn(move |cx| {
let end_result = fut.poll_unpin(cx);

if let Ok(maybe_result) = rx.try_next() {
if let Poll::Ready(maybe_result) = rx.poll_next_unpin(cx) {
return Poll::Ready(maybe_result);
}

end_result.map(|()| None)
fut.poll_unpin(cx).map(|()| None)
})
}

Expand Down

0 comments on commit 8de49f4

Please sign in to comment.