Commit c1b1f25e authored by Marc Gravell's avatar Marc Gravell

in RecordConnectionFailed, don't shout very loud if we deliberately burned the pipe

parent 1dfc5d20
...@@ -45,7 +45,7 @@ public async Task SetMembers() ...@@ -45,7 +45,7 @@ public async Task SetMembers()
[FactLongRunning] [FactLongRunning]
public async Task SetUnion() public async Task SetUnion()
{ {
using (var conn = Create()) using (var conn = Create(syncTimeout: 10000))
{ {
var db = conn.GetDatabase(); var db = conn.GetDatabase();
......
...@@ -15,6 +15,7 @@ internal sealed partial class CompletionManager ...@@ -15,6 +15,7 @@ internal sealed partial class CompletionManager
internal static void CompleteSyncOrAsyncImpl(CompletionManager manager, ICompletable operation) internal static void CompleteSyncOrAsyncImpl(CompletionManager manager, ICompletable operation)
{ {
if (operation == null) return;
if (manager != null) manager.PerInstanceCompleteSyncOrAsync(operation); if (manager != null) manager.PerInstanceCompleteSyncOrAsync(operation);
else SharedCompleteSyncOrAsync(operation); else SharedCompleteSyncOrAsync(operation);
} }
...@@ -32,7 +33,6 @@ public CompletionManager(ConnectionMultiplexer multiplexer, string name) ...@@ -32,7 +33,6 @@ public CompletionManager(ConnectionMultiplexer multiplexer, string name)
private static void SharedCompleteSyncOrAsync(ICompletable operation) private static void SharedCompleteSyncOrAsync(ICompletable operation)
{ {
if (operation == null) return;
if (!operation.TryComplete(false)) if (!operation.TryComplete(false))
{ {
SocketManager.Shared.ScheduleTask(s_AnyOrderCompletionHandler, operation); SocketManager.Shared.ScheduleTask(s_AnyOrderCompletionHandler, operation);
...@@ -40,7 +40,6 @@ private static void SharedCompleteSyncOrAsync(ICompletable operation) ...@@ -40,7 +40,6 @@ private static void SharedCompleteSyncOrAsync(ICompletable operation)
} }
private void PerInstanceCompleteSyncOrAsync(ICompletable operation) private void PerInstanceCompleteSyncOrAsync(ICompletable operation)
{ {
if (operation == null) return;
if (operation.TryComplete(false)) if (operation.TryComplete(false))
{ {
multiplexer.Trace("Completed synchronously: " + operation, name); multiplexer.Trace("Completed synchronously: " + operation, name);
......
...@@ -97,6 +97,8 @@ public void Dispose() ...@@ -97,6 +97,8 @@ public void Dispose()
} }
~PhysicalBridge() ~PhysicalBridge()
{ {
isDisposed = true; // make damn sure we don't true to resurrect
// shouldn't *really* touch managed objects // shouldn't *really* touch managed objects
// in a finalizer, but we need to kill that socket, // in a finalizer, but we need to kill that socket,
// and this is the first place that isn't going to // and this is the first place that isn't going to
......
...@@ -242,6 +242,7 @@ internal void Shutdown() ...@@ -242,6 +242,7 @@ internal void Shutdown()
if (ioPipe != null) if (ioPipe != null)
{ {
Trace("Disconnecting..."); Trace("Disconnecting...");
try { BridgeCouldBeNull?.OnDisconnected(ConnectionFailureType.ConnectionDisposed, this, out _, out _); } catch { }
try { ioPipe.Input?.CancelPendingRead(); } catch { } try { ioPipe.Input?.CancelPendingRead(); } catch { }
try { ioPipe.Input?.Complete(); } catch { } try { ioPipe.Input?.Complete(); } catch { }
try { ioPipe.Output?.CancelPendingFlush(); } catch { } try { ioPipe.Output?.CancelPendingFlush(); } catch { }
...@@ -291,9 +292,12 @@ public Task FlushAsync() ...@@ -291,9 +292,12 @@ public Task FlushAsync()
public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null) public void RecordConnectionFailed(ConnectionFailureType failureType, Exception innerException = null, [CallerMemberName] string origin = null)
{ {
Exception outerException = innerException; Exception outerException = innerException;
IdentifyFailureType(innerException, ref failureType); IdentifyFailureType(innerException, ref failureType);
if (_ioPipe != null) // if *we* didn't burn the pipe: flag it
{
if (failureType == ConnectionFailureType.InternalFailure) OnInternalError(innerException, origin); if (failureType == ConnectionFailureType.InternalFailure) OnInternalError(innerException, origin);
// stop anything new coming in... // stop anything new coming in...
...@@ -367,7 +371,7 @@ void add(string lk, string sk, string v) ...@@ -367,7 +371,7 @@ void add(string lk, string sk, string v)
BridgeCouldBeNull?.OnConnectionFailed(this, failureType, outerException); BridgeCouldBeNull?.OnConnectionFailed(this, failureType, outerException);
} }
}
// cleanup // cleanup
lock (_writtenAwaitingResponse) lock (_writtenAwaitingResponse)
{ {
......
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