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

1.x: fix: bounded replay() not requesting enough for latecommers #3454

Merged
merged 1 commit into from Dec 14, 2015

Conversation

akarnokd
Copy link
Member

Fixes the bug reported in #3452.

The fix involves 3 changes:

  • First, each node in the bounded buffer receives an incrementing index whenever they are created. The root node starts with 0, the first value's index will be 1 and so on.
  • In the replay logic, the very first time the current node is captured, the node's index is added to the totalRequested amount of the subscriber. Since this is always one less than the max requested that far, there is no point in calling manageRequests() at this point.
  • Third, the pinning of the current node has to happen before the child requests, otherwise the difference would manifest before the compensation and some elements may get missed.

In addition, there was a missing r-- in the emission loop and thus the operator could have overflown its child subscriber.

@benjchristensen
Copy link
Member

Don't have the time to fully grok this, but the changes look okay and I trust @akarnokd on this. So 👍

@akarnokd
Copy link
Member Author

Thank you @benjchristensen. Since replay() is one of the most complicated operators, I'd like @abersnaze or @stealthcode to look at it before it ends up in 1.0.15.

@stealthcode
Copy link

👍

akarnokd added a commit that referenced this pull request Dec 14, 2015
1.x: fix: bounded replay() not requesting enough for latecommers
@akarnokd akarnokd merged commit 3be980d into ReactiveX:1.x Dec 14, 2015
@akarnokd akarnokd deleted the ReplayRequestCoordinationFix branch December 14, 2015 19:10
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.

None yet

3 participants