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

close #2314 - fixes shutdown race condition with HashedWheelTimer #2315

Merged
merged 1 commit into from
Sep 21, 2016
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
5 changes: 3 additions & 2 deletions src/core/Akka/Actor/Scheduler/HashedWheelTimerScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,11 @@ protected override void InternalScheduleRepeatedly(TimeSpan initialDelay, TimeSp
private Task<IEnumerable<SchedulerRegistration>> Stop()
{
var p = new TaskCompletionSource<IEnumerable<SchedulerRegistration>>();

if (_stopped.CompareAndSet(null, p)
#pragma warning disable 420
if (Interlocked.CompareExchange(ref _workerState, WORKER_STATE_SHUTDOWN, WORKER_STATE_STARTED) == WORKER_STATE_STARTED
&& Interlocked.CompareExchange(ref _workerState, WORKER_STATE_SHUTDOWN, WORKER_STATE_STARTED) == WORKER_STATE_STARTED)
#pragma warning restore 420
&& _stopped.CompareAndSet(null, p))
{
// Let remaining work that is already being processed finished. The termination task will complete afterwards
return p.Task;
Expand Down