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

Fixed race in UnicastContentSubject and discard of connection #310

Merged
merged 4 commits into from
Jan 14, 2015

Conversation

NiteshKant
Copy link
Member

Race conditions in UnicastContentSubject.

UnicastContentSubject has a potential to loose terminal events sent to the subject due to a race condition.
The race condition was when a terminal event arrives between draining all buffered notifications and atomically replacing the observer. Since, the observer, was draining all such buffered notifications, on recieving a notifications, the terminal notifications mentioned above were lost.

This subject was copied from RxJava BufferTillSubscriber which had fixed this race. The intention of not using that subject in RxJava was that it was an internal class. The tax of such bugs is high as compared to rxjava changing the subject contract, hence, using rxjava's subject now.

Mark connection as disposed before close.

On unsubscribe, without getting a response, the discard connection flag was not set before close() was called.
This lead to the connection which is supposed to be discarded, return to the pool and potentially used by another request.
This will cause a request to immediately fail since the connection will be closed (as a result of conn. release event) before the request is written.

Now, marking the connection as disposed, when the unsubscribe happens before completion of response.

Nitesh Kant added 4 commits December 5, 2014 10:01
UnicastContentSubject has a potential to loose terminal events sent to the subject due to a race condition.
The race condition was when a terminal event arrives between draining all buffered notifications and atomically replacing the observer. Since, the observer, was draining all such buffered notifications, on recieving a notifications, the terminal notifications mentioned above were lost.

This subject was copied from RxJava BufferTillSubscriber which had fixed this race. The intention of not using that subject in RxJava was that it was an internal class. The tax of such bugs is high as compared to rxjava changing the subject contract, hence, I am using rxjava's subject now.
On unsubscribe, without getting a response, the discard connection flag was not set before close() was called.
This lead to the connection which is supposed to be discarded, return to the pool and potentially used by another request.
This will cause a request to immediately fail since the connection will be closed (as a result of conn. release event) before the request is written.

Now, marking the connection as disposed, when the unsubscribe happens before completion of response.
@NiteshKant NiteshKant modified the milestone: 0.4.5 Jan 14, 2015
NiteshKant added a commit that referenced this pull request Jan 14, 2015
Fixed race in UnicastContentSubject and discard of connection
@NiteshKant NiteshKant merged commit 1bfa5da into ReactiveX:0.x Jan 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant