From a32c4573adf4b27ca37bc1b1622632687bf8c372 Mon Sep 17 00:00:00 2001 From: Vorspire Date: Sun, 23 Aug 2015 02:13:49 +0100 Subject: [PATCH] + Execute and store the results of the Linq query as a List to prevent collection modified exceptions. * The List is a member of PooledEnumerable and is thus pooled along with it. --- Server/Map.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Server/Map.cs b/Server/Map.cs index f4580c557..1a0c30b1a 100644 --- a/Server/Map.cs +++ b/Server/Map.cs @@ -1743,7 +1743,7 @@ namespace Server if (e != null) { - e._Pool = pool; + e._Pool.AddRange(pool); } else { @@ -1754,11 +1754,11 @@ namespace Server } private bool _IsDisposed; - private IEnumerable _Pool; + private List _Pool; public PooledEnumerable(IEnumerable pool) { - _Pool = pool; + _Pool = new List(pool); } IEnumerator IEnumerable.GetEnumerator() @@ -1778,7 +1778,7 @@ namespace Server return; } - _Pool = null; + _Pool.Clear(); lock (((ICollection)_Buffer).SyncRoot) { @@ -1789,6 +1789,9 @@ namespace Server public void Dispose() { _IsDisposed = true; + + _Pool.Clear(); + _Pool.TrimExcess(); _Pool = null; } }