Commit 77633383 authored by Nick Craver's avatar Nick Craver

Remove GCHandle (screws with GC testing)

parent 8d015446
...@@ -200,8 +200,6 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer) ...@@ -200,8 +200,6 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer)
throw new InvalidOperationException("Requires a master endpoint (found none)"); throw new InvalidOperationException("Requires a master endpoint (found none)");
} }
private static readonly HashSet<GCHandle> ActiveMultiplexers = new HashSet<GCHandle>();
protected virtual ConnectionMultiplexer Create( protected virtual ConnectionMultiplexer Create(
string clientName = null, int? syncTimeout = null, bool? allowAdmin = null, int? keepAlive = null, string clientName = null, int? syncTimeout = null, bool? allowAdmin = null, int? keepAlive = null,
int? connectTimeout = null, string password = null, string tieBreaker = null, TextWriter log = null, int? connectTimeout = null, string password = null, string tieBreaker = null, TextWriter log = null,
...@@ -212,7 +210,6 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer) ...@@ -212,7 +210,6 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer)
[CallerMemberName] string caller = null) [CallerMemberName] string caller = null)
{ {
StringWriter localLog = null; StringWriter localLog = null;
GCHandle handle;
if(log == null) if(log == null)
{ {
log = localLog = new StringWriter(); log = localLog = new StringWriter();
...@@ -274,12 +271,6 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer) ...@@ -274,12 +271,6 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer)
Skip.Inconclusive(failMessage + "Server is not available"); Skip.Inconclusive(failMessage + "Server is not available");
} }
handle = GCHandle.Alloc(muxer);
lock (ActiveMultiplexers)
{
ActiveMultiplexers.Add(handle);
}
muxer.InternalError += OnInternalError; muxer.InternalError += OnInternalError;
muxer.ConnectionFailed += OnConnectionFailed; muxer.ConnectionFailed += OnConnectionFailed;
muxer.MessageFaulted += (msg, ex, origin) => muxer.MessageFaulted += (msg, ex, origin) =>
...@@ -297,19 +288,7 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer) ...@@ -297,19 +288,7 @@ protected IServer GetAnyMaster(ConnectionMultiplexer muxer)
} }
muxer.InfoMessage += msg => Writer.WriteLine(msg); muxer.InfoMessage += msg => Writer.WriteLine(msg);
muxer.Resurrecting += (e, t) => Writer.WriteLine($"Resurrecting {Format.ToString(e)} as {t}"); muxer.Resurrecting += (e, t) => Writer.WriteLine($"Resurrecting {Format.ToString(e)} as {t}");
muxer.Closing += complete => muxer.Closing += complete => Writer.WriteLine(complete ? "Closed" : "Closing...");
{
int count;
lock(ActiveMultiplexers)
{
count = ActiveMultiplexers.Count;
if (complete)
{
ActiveMultiplexers.Remove(handle);
}
}
Writer.WriteLine((complete ? "Closed (" : "Closing... (") + count.ToString() + " remaining)");
};
return muxer; return muxer;
} }
catch catch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment