internal void Fail(int connection, Exception reason)
{
var currentState = PortStates[connection];
if (IsDebug) Console.WriteLine($"{Name} Fail({connection}, {reason}) [{currentState}]");
PortStates[connection] = currentState | OutClosed;
if ((currentState & (InClosed | OutClosed)) == 0)
{
PortStates[connection] = currentState | (OutClosed | InFailed);
ConnectionSlots[connection] = new Failed(reason, ConnectionSlots[connection]);
if ((currentState & (Pulling | Pushing)) == 0)
Enqueue(connection);
}
if ((currentState & OutClosed) == 0)
CompleteConnection(Assembly.OutletOwners[connection]);
}