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 Observable.from(Iterable) race condition #2895

Merged
merged 1 commit into from
Apr 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ private IterableProducer(Subscriber<? super T> o, Iterator<? extends T> it) {

@Override
public void request(long n) {
if (REQUESTED_UPDATER.get(this) == Long.MAX_VALUE) {
if (requested == Long.MAX_VALUE) {
// already started with fast-path
return;
}
if (n == Long.MAX_VALUE) {
REQUESTED_UPDATER.set(this, n);
if (n == Long.MAX_VALUE && REQUESTED_UPDATER.compareAndSet(this, 0, Long.MAX_VALUE)) {
// fast-path without backpressure
while (it.hasNext()) {
if (o.isUnsubscribed()) {
Expand All @@ -78,7 +77,7 @@ public void request(long n) {
if (!o.isUnsubscribed()) {
o.onCompleted();
}
} else if(n > 0) {
} else if (n > 0) {
// backpressure is requested
long _c = BackpressureUtils.getAndAddRequest(REQUESTED_UPDATER, this, n);
if (_c == 0) {
Expand Down