Skip to content

Fix an unsubscribe race in EventLoopWorker#3868

Merged
zsxwing merged 1 commit intoReactiveX:1.xfrom
zsxwing:event-loop-race
Apr 20, 2016
Merged

Fix an unsubscribe race in EventLoopWorker#3868
zsxwing merged 1 commit intoReactiveX:1.xfrom
zsxwing:event-loop-race

Conversation

@zsxwing
Copy link
Member

@zsxwing zsxwing commented Apr 20, 2016

There is an unsubscribe race condition similar to #3842 in CachedThreadScheduler.EventLoopWorker and EventLoopsScheduler.EventLoopWorker. Image the following execution order:

Execution Order thread 1 thread 2
1 submit task A
2 submit task B
3 unsubscribe Worker
4 unsubscribe task A
5 task A won't run as it's unsubscribed
6 run task B
7 unsubscribe task B

So task B will run but its previous task A will be skipped.

This PR adds a check before running an action and moves workerUnderConcurrentUnsubscribeShouldNotAllowLaterTasksToRunDueToUnsubscriptionRace to AbstractSchedulerConcurrencyTests to test all concurrent schedulers.

@akarnokd
Copy link
Member

👍

@zsxwing zsxwing merged commit 8af2bc9 into ReactiveX:1.x Apr 20, 2016
@zsxwing zsxwing deleted the event-loop-race branch April 20, 2016 17:03
@davidmoten
Copy link
Collaborator

👍 Thanks @zsxwing

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.

3 participants