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 deadlock in Subjects + OperatorCache. #972

Merged
merged 1 commit into from
Apr 16, 2014

Conversation

akarnokd
Copy link
Member

Fix for Issue #971.

  • I had to rewrite OperatorCache to allow testing for deadlocks in all Subject types.
  • The terminationLatch was unnecessarily waiting for existing subscribers to deliver their termination events, which caused deadlock with repeat().
  • Treating subjects as internal implementations was not necessary to fix the problem.

@cloudbees-pull-request-builder

RxJava-pull-requests #912 SUCCESS
This pull request looks good

@benjchristensen
Copy link
Member

I don't understand these changes yet, but on first review they are very awkward as the SubjectSubscriptionManager methods now both invoke a function and return a collection.

@akarnokd
Copy link
Member Author

True, the rewritten Subjects don't require an Action1, they are fine with Action0. The changes had to be made since the CountDonwLatch logic acted as a synchronization block and emitting events while holding locks is prone to deadlocks, as the associated issue demonstrates.

@benjchristensen
Copy link
Member

Ah, holding the lock is the issue. We should find a way of doing that without the latches at all, as it is blocking.

@akarnokd
Copy link
Member Author

The latch has its use because once the state has been swapped to terminal state, we still need to perform some tasks on any related state within the particular subject before client notifications can resume: usually, it is to set the last event which then will be available to newcomers.

@benjchristensen
Copy link
Member

I haven't merged this yet as I need to spend time better understanding this and the impact on design.

benjchristensen added a commit to benjchristensen/RxJava that referenced this pull request Apr 15, 2014
Since the collection is being returned we don't want to also inject it as an argument, so I migrated to Action0 from Action1 as per discussion at ReactiveX#972 (comment)
@benjchristensen
Copy link
Member

Since this has conflicts and I did some cleanup based on our discussion above, I've opened #1040 for merging this.

@benjchristensen benjchristensen merged commit ceff938 into ReactiveX:master Apr 16, 2014
benjchristensen added a commit that referenced this pull request Apr 16, 2014
@akarnokd akarnokd deleted the SubjectDeadlockFix320 branch May 6, 2014 13:39
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.

3 participants