-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: Fix refCount() connect/subscribe/cancel deadlock #5975
Conversation
public void blockingSourceAsnycCancel() throws Exception { | ||
BehaviorProcessor<Integer> bp = BehaviorProcessor.createDefault(1); | ||
|
||
Flowable<Integer> o = bp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be f
Codecov Report
@@ Coverage Diff @@
## 2.x #5975 +/- ##
===========================================
- Coverage 98.27% 98.2% -0.07%
- Complexity 6019 6049 +30
===========================================
Files 656 656
Lines 44037 44074 +37
Branches 6100 6118 +18
===========================================
+ Hits 43278 43285 +7
- Misses 224 246 +22
- Partials 535 543 +8
Continue to review full report at Codecov.
|
/cc @davidmoten as you devised the previous |
👍 Great to see that bit of locking removed. I actually had launched into a non-blocking rewrite of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, but comment :)
} | ||
|
||
long c = conn.subscriberCount; | ||
if (c == 0L && conn.timer != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this condition is only actual for resubscribeBeforeTimeout
test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange to see logic and tests for something that user cannot use in RxJava
As you mentioned in PR description, let's maybe expose additional time related refCount api or try to shrink unused code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #5986.
This PR fixes a deadlock issue with the
refCount
operator when a subscription leads to a blocking execution while the lock is being held, preventing other subscription or cancellation from executing on other threads.The bug was discovered as the cause of a reported hang on the Google groups.
The code has been developed in the extensions project where the operator has more features. The overloads supporting these features can be added in a separate enhancement PR.