diff --git a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs index 0edb0313db5..47e05feb522 100644 --- a/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs +++ b/src/core/Akka/Actor/ChildrenContainer/Internal/ChildStats.cs @@ -47,12 +47,18 @@ public ChildRestartStats(InternalActorRef child, uint maxNrOfRetriesCount = 0, l public bool RequestRestartPermission(int maxNrOfRetries, int withinTimeMilliseconds) { if (maxNrOfRetries == 0) return false; - if (withinTimeMilliseconds == 0) + var retriesIsDefined = maxNrOfRetries > 0; + var windowIsDefined = withinTimeMilliseconds > 0; + if (retriesIsDefined && !windowIsDefined) { _maxNrOfRetriesCount++; return _maxNrOfRetriesCount <= maxNrOfRetries; } - return RetriesInWindowOkay(maxNrOfRetries, withinTimeMilliseconds); + if (windowIsDefined) + { + return RetriesInWindowOkay(retriesIsDefined ? maxNrOfRetries : 1, withinTimeMilliseconds); + } + return true; //retriesWindow match { // case (Some(retries), _) if retries < 1 ⇒ false // case (Some(retries), None) ⇒ { maxNrOfRetriesCount += 1; maxNrOfRetriesCount <= retries } @@ -78,7 +84,7 @@ private bool RetriesInWindowOkay(int retries, int windowInMilliseconds) { windowStart = _restartTimeWindowStartTicks; } - var windowInTicks = windowInMilliseconds*TimeSpan.TicksPerMillisecond; + var windowInTicks = windowInMilliseconds * TimeSpan.TicksPerMillisecond; var insideWindow = (now - windowStart) <= windowInTicks; if (insideWindow) @@ -90,5 +96,7 @@ private bool RetriesInWindowOkay(int retries, int windowInMilliseconds) _restartTimeWindowStartTicks = now; return true; } + + } } \ No newline at end of file