fix: Fixes timer wheel edge cases (#782)
1. Stopping a different timer, on the same slot as the timer being executed during OnTick
* Adds a check for the timer wheel currently being executed and does not detach the timer on Stop().
1. Timers are added to the current slot if they need 4095 slots, before the chain is fully detached/executed
* Removes all chains that will be executed from the timer wheel before executing.
This commit is contained in:
parent
bba5346a92
commit
7785f7e06c
3 changed files with 55 additions and 29 deletions
|
|
@ -102,13 +102,18 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
// We are at the head
|
||||
if (_rings[_ring][_slot] == this)
|
||||
// Do not detach if we are in the middle of executing the timer wheel for this ring/slot
|
||||
if (!_timerWheelExecuting || _ringIndexes[_ring] != _slot)
|
||||
{
|
||||
_rings[_ring][_slot] = _nextTimer;
|
||||
// We are at the head
|
||||
if (_rings[_ring][_slot] == this)
|
||||
{
|
||||
_rings[_ring][_slot] = _nextTimer;
|
||||
}
|
||||
|
||||
Detach();
|
||||
}
|
||||
|
||||
Detach();
|
||||
Running = false;
|
||||
Version++;
|
||||
var prof = GetProfile();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue