Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect termination of select_with_strategy streams #2635

Merged
merged 3 commits into from Aug 21, 2022

Conversation

Sushisource
Copy link
Contributor

@Sushisource Sushisource commented Aug 16, 2022

Fixes #2634

I can add a test tomorrow (not sure exactly where, if I get a pointer that would be lovely) or maintainers are welcome to add it to my PR.

@414owen
Copy link
Contributor

414owen commented Aug 16, 2022

So, the finish function uses ps: PollNext to mean the stream that you want to mark as finished.
When the internal state is LeftFinished and you're marking Right as finished, the internal state should transition to BothFinished.

Note the lines above your change:

(InternalState::Start, PollNext::Right) => {
  *self = InternalState::RightFinished;
}

Which reads when neither are finished and we mark Right as finished, then Right is Finished.

Admittedly I should probably have used a differently named enum that's isomorphic to PollNext for ps.

@Sushisource What kind of funky behaviour are you seeing exactly? The tests are in futures/tests/stream.rs, so a good first step would be to add a failing test there :)

@Sushisource
Copy link
Contributor Author

Sushisource commented Aug 16, 2022

@414owen I've added a failing test. The problem behavior is that the left stream never terminated, but once the right stream does, if my strategy is to always poll left, the select_with_strategy stream then terminates.

And, indeed, what I changed hasn't fixed it. I'll poke around a bit and see what would, or if you see this first and know what the problem is, awesome :)

Think I've figured it out and fixed it. Problem was the poll_inner check was returning Poll::Ready(None) when the "other" stream is done, even if the first stream was not yet done.

@Sushisource Sushisource force-pushed the fix-select-strat-regression branch 2 times, most recently from 8088366 to 3b8ad5c Compare August 16, 2022 17:18
Copy link
Contributor

@414owen 414owen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sushisource Nice work. Great to have a test case covering this. 🚀

@taiki-e taiki-e added A-stream Area: futures::stream 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. labels Aug 21, 2022
Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Sushisource for the fix, and thanks @414owen for the review!

@taiki-e taiki-e merged commit 9e4446e into rust-lang:master Aug 21, 2022
@Sushisource Sushisource deleted the fix-select-strat-regression branch August 22, 2022 16:44
@QuentinPerez
Copy link

👋 we've faced the same issue, nice to see that has been fixed 👍
Do you think that we could have a new minor with that patch soon ?

@taiki-e taiki-e mentioned this pull request Aug 29, 2022
@taiki-e taiki-e added 0.3-backport: completed and removed 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. labels Aug 29, 2022
@taiki-e
Copy link
Member

taiki-e commented Aug 29, 2022

Published in 0.3.24.

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Sep 1, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [futures](https://rust-lang.github.io/futures-rs) ([source](https://github.com/rust-lang/futures-rs)) | dependencies | patch | `0.3.23` -> `0.3.24` |

---

### Release Notes

<details>
<summary>rust-lang/futures-rs</summary>

### [`v0.3.24`](https://github.com/rust-lang/futures-rs/blob/HEAD/CHANGELOG.md#&#8203;0324---2022-08-29)

[Compare Source](rust-lang/futures-rs@0.3.23...0.3.24)

-   Fix incorrect termination of `select_with_strategy` streams ([#&#8203;2635](rust-lang/futures-rs#2635))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xODEuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE4MS4wIn0=-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1529
Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

https://github.com/rust-lang/futures-rs/pull/2583 introduced regression in select_with_strategy
4 participants