Commit 8a3f264a authored by Marc Gravell's avatar Marc Gravell

don't be so aggressive about adding PINGs if we're already backed up; no need...

don't be so aggressive about adding PINGs if we're already backed up; no need to report QUIT as faulted if the socket died (that's always a race)
parent 78d04c28
......@@ -619,6 +619,8 @@ internal void SetException(Exception exception)
resultBox?.SetException(exception);
}
internal bool TrySetResult<T>(T value) => resultBox is ResultBox<T> typed && typed.TrySetResult(value);
internal void SetEnqueued() => performance?.SetEnqueued();
internal void SetRequestSent()
......
......@@ -260,6 +260,7 @@ internal void KeepAlive()
}
break;
}
if (msg != null)
{
msg.SetInternalCall();
......@@ -460,7 +461,9 @@ internal void OnHeartbeat(bool ifConnectedOnly)
OnDisconnected(ConnectionFailureType.SocketFailure, tmp, out bool ignore, out State oldState);
}
}
else if (tmp.GetSentAwaitingResponseCount() != 0)
else if (writeEverySeconds <= 0 && tmp.IsIdle()
&& tmp.LastWriteSecondsAgo > 2
&& tmp.GetSentAwaitingResponseCount() != 0)
{
// there's a chance this is a dead socket; sending data will shake that
// up a bit, so if we have an empty unsent queue and a non-empty sent
......
......@@ -399,13 +399,21 @@ void add(string lk, string sk, string v)
while (_writtenAwaitingResponse.Count != 0)
{
var next = _writtenAwaitingResponse.Dequeue();
var ex = innerException is RedisException ? innerException : outerException;
if (bridge != null)
if (next.Command == RedisCommand.QUIT && next.TrySetResult(true))
{
// fine, death of a socket is close enough
}
else
{
bridge.Trace("Failing: " + next);
bridge.Multiplexer?.OnMessageFaulted(next, ex, origin);
var ex = innerException is RedisException ? innerException : outerException;
if (bridge != null)
{
bridge.Trace("Failing: " + next);
bridge.Multiplexer?.OnMessageFaulted(next, ex, origin);
}
next.SetException(ex);
}
next.SetException(ex);
bridge.CompleteSyncOrAsync(next);
}
}
......
......@@ -82,6 +82,13 @@ public void SetResult(T value)
this.value = value;
}
internal bool TrySetResult(T value)
{
if (_exception != null) return false;
this.value = value;
return true;
}
public override bool IsAsync => stateOrCompletionSource is TaskCompletionSource<T>;
public override bool TryComplete(bool isAsync)
......
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