Skip to content

Commit

Permalink
fix extras racecondition for cancellation token (#1965)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing authored Apr 4, 2023
1 parent b6cf8bb commit 9736e45
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Proto.Actor/Context/ActorContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,21 @@ private ActorContextExtras EnsureExtras()
return _extras;
}

var context = _props.ContextDecoratorChain?.Invoke(this) ?? this;
_extras = new ActorContextExtras(context);

//YOLO: nobody else should touch this....
#pragma warning disable RCS1059
lock (this)
#pragma warning restore RCS1059
{
//early exit if another thread already created the extras
if (_extras is not null)
{
return _extras;
}

var context = _props.ContextDecoratorChain?.Invoke(this) ?? this;
_extras = new ActorContextExtras(context);
}

return _extras;
}
Expand Down

0 comments on commit 9736e45

Please sign in to comment.