Skip to content

prevent take() from requesting more than needed #2989

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

Merged
merged 1 commit into from
May 29, 2015

Conversation

davidmoten
Copy link
Collaborator

The request method used logic that could overrequest upstream if multiple small requests were made before the next item arrived.

Added a unit test that failed on previous code.

// ensure we only request as much as needed, no more no less
while (true) {
long r = requested.get();
long c = Math.min(n, limit - requested.get());
Copy link
Member

Choose a reason for hiding this comment

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

Re-read of a volatile value, you need limit - r.

@davidmoten
Copy link
Collaborator Author

Thanks @akarnokd. Changes made.

@akarnokd
Copy link
Member

Great job!

akarnokd added a commit that referenced this pull request May 29, 2015
prevent take() from requesting more than needed
@akarnokd akarnokd merged commit da588a2 into ReactiveX:1.x May 29, 2015
@akarnokd akarnokd added the Bug label May 29, 2015
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.

2 participants