fix: Fixes massive capacity bug with pooled ref queue/list (#1865)

This commit is contained in:
Kamron Batman 2024-07-07 16:18:56 -07:00 • committed by GitHub
parent 96de1fdaa1
commit 21836cf62f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 30 deletions

View file

@ -6,7 +6,6 @@ using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Server.Buffers; using Server.Buffers;
namespace Server.Collections; namespace Server.Collections;
@ -152,14 +151,14 @@ public ref struct PooledRefList<T>
if (_items.Length > 0) if (_items.Length > 0)
{ {
Clear(); Array.Clear(_items);
ArrayPool.Return(_items); ArrayPool.Return(_items);
} }
_items = newItems; _items = newItems;
} }
else else
{ {
Clear(); Array.Clear(_items);
ArrayPool.Return(_items); ArrayPool.Return(_items);
_items = s_emptyArray; _items = s_emptyArray;
} }

View file

@ -305,7 +305,7 @@ public ref struct PooledRefQueue<T>
if (_array.Length > 0) if (_array.Length > 0)
{ {
Clear(); Array.Clear(_array);
(_mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Return(_array); (_mt ? ArrayPool<T>.Shared : STArrayPool<T>.Shared).Return(_array);
} }

View file

@ -2,19 +2,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using Server.Accounting; using Server.Accounting;
using Server.Engines.CannedEvil;
using Server.Engines.Help; using Server.Engines.Help;
using Server.Engines.PlayerMurderSystem;
using Server.Engines.Virtues;
using Server.Logging; using Server.Logging;
using Server.Network; using Server.Network;
using Server.Regions; using Server.Regions;
using Server.Spells.Fifth;
using Server.Spells.First;
using Server.Spells.Mysticism;
using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu;
using Server.Spells.Second;
namespace Server.Misc; namespace Server.Misc;
@ -236,20 +227,6 @@ public static class AccountHandler
m.Delete(); m.Delete();
StaminaSystem.OnPlayerDeleted(m);
JusticeVirtue.OnPlayerDeleted(m);
PlayerMurderSystem.OnPlayerDeleted(m);
ChampionTitleSystem.OnPlayerDeleted(m);
// Spells
MagicReflectSpell.EndReflect(m);
ReactiveArmorSpell.EndArmor(m);
ProtectionSpell.EndProtection(m);
StoneFormSpell.RemoveEffects(m);
AnimateDeadSpell.RemoveEffects(m);
SummonFamiliarSpell.RemoveEffects(m);
AnimalForm.RemoveLastAnimalForm(m);
state.SendCharacterListUpdate(acct); state.SendCharacterListUpdate(acct);
return; return;
} }

View file

@ -28,9 +28,12 @@ using Server.SkillHandlers;
using Server.Spells; using Server.Spells;
using Server.Spells.Bushido; using Server.Spells.Bushido;
using Server.Spells.Fifth; using Server.Spells.Fifth;
using Server.Spells.First;
using Server.Spells.Fourth; using Server.Spells.Fourth;
using Server.Spells.Mysticism;
using Server.Spells.Necromancy; using Server.Spells.Necromancy;
using Server.Spells.Ninjitsu; using Server.Spells.Ninjitsu;
using Server.Spells.Second;
using Server.Spells.Seventh; using Server.Spells.Seventh;
using Server.Spells.Sixth; using Server.Spells.Sixth;
using Server.Spells.Spellweaving; using Server.Spells.Spellweaving;
@ -3382,14 +3385,25 @@ namespace Server.Mobiles
base.OnAfterDelete(); base.OnAfterDelete();
var faction = Faction.Find(this); var faction = Faction.Find(this);
faction?.RemoveMember(this); faction?.RemoveMember(this);
MLQuestSystem.HandleDeletion(this); MLQuestSystem.HandleDeletion(this);
BaseHouse.HandleDeletion(this); BaseHouse.HandleDeletion(this);
DisguisePersistence.RemoveTimer(this); DisguisePersistence.RemoveTimer(this);
StaminaSystem.OnPlayerDeleted(this);
JusticeVirtue.OnPlayerDeleted(this);
PlayerMurderSystem.OnPlayerDeleted(this);
ChampionTitleSystem.OnPlayerDeleted(this);
// Spells
MagicReflectSpell.EndReflect(this);
ReactiveArmorSpell.EndArmor(this);
ProtectionSpell.EndProtection(this);
StoneFormSpell.RemoveEffects(this);
AnimateDeadSpell.RemoveEffects(this);
SummonFamiliarSpell.RemoveEffects(this);
AnimalForm.RemoveLastAnimalForm(this);
} }
public override void GetProperties(IPropertyList list) public override void GetProperties(IPropertyList list)