Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/StackExchange.Redis/PhysicalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private static readonly Message

private int failureReported;

private int clientSentQuit;

private int lastWriteTickCount, lastReadTickCount, lastBeatTickCount;

private long bytesLastResult;
Expand Down Expand Up @@ -375,15 +377,6 @@ internal void SimulateConnectionFailure(SimulatedFailureType failureType)
}
}

/// <summary>
/// Did we ask for the shutdown? If so this leads to informational messages for tracking but not errors.
/// </summary>
private bool IsRequestedShutdown(PipeShutdownKind kind) => kind switch
{
PipeShutdownKind.ProtocolExitClient => true,
_ => false,
};

public void RecordConnectionFailed(
ConnectionFailureType failureType,
Exception? innerException = null,
Expand Down Expand Up @@ -436,12 +429,12 @@ public void RecordConnectionFailed(

var exMessage = new StringBuilder(failureType.ToString());

// If the reason for the shutdown was we asked for the socket to die, don't log it as an error (only informational)
weAskedForThis = Thread.VolatileRead(ref clientSentQuit) != 0;

var pipe = connectingPipe ?? _ioPipe;
if (pipe is SocketConnection sc)
{
// If the reason for the shutdown was we asked for the socket to die, don't log it as an error (only informational)
weAskedForThis = IsRequestedShutdown(sc.ShutdownKind);

exMessage.Append(" (").Append(sc.ShutdownKind);
if (sc.SocketError != SocketError.Success)
{
Expand Down Expand Up @@ -904,8 +897,12 @@ internal void WriteHeader(RedisCommand command, int arguments, CommandBytes comm

internal void WriteRaw(ReadOnlySpan<byte> bytes) => _ioPipe?.Output?.Write(bytes);

internal void RecordQuit() // don't blame redis if we fired the first shot
=> (_ioPipe as SocketConnection)?.TrySetProtocolShutdown(PipeShutdownKind.ProtocolExitClient);
internal void RecordQuit()
{
// don't blame redis if we fired the first shot
Thread.VolatileWrite(ref clientSentQuit, 1);
(_ioPipe as SocketConnection)?.TrySetProtocolShutdown(PipeShutdownKind.ProtocolExitClient);
}

internal static void WriteMultiBulkHeader(PipeWriter output, long count)
{
Expand Down
Loading