Commit e6a3e65b authored by Nick Craver's avatar Nick Craver

Line endings fix: partial files

parent 20fa2587
...@@ -68,7 +68,7 @@ private void CheckSame(RedisValue x, RedisValue y) ...@@ -68,7 +68,7 @@ private void CheckSame(RedisValue x, RedisValue y)
Assert.True(y.Equals(x)); Assert.True(y.Equals(x));
Assert.True(x.GetHashCode() == y.GetHashCode()); Assert.True(x.GetHashCode() == y.GetHashCode());
} }
private void CheckNotSame(RedisValue x, RedisValue y) private void CheckNotSame(RedisValue x, RedisValue y)
{ {
Assert.False(Equals(x, y)); Assert.False(Equals(x, y));
...@@ -92,7 +92,7 @@ private void CheckNotNull(RedisValue value) ...@@ -92,7 +92,7 @@ private void CheckNotNull(RedisValue value)
CheckNotSame(value, (string)null); CheckNotSame(value, (string)null);
CheckNotSame(value, (byte[])null); CheckNotSame(value, (byte[])null);
} }
private void CheckNull(RedisValue value) private void CheckNull(RedisValue value)
{ {
Assert.True(value.IsNull); Assert.True(value.IsNull);
......
...@@ -30,8 +30,8 @@ internal RedisServer(ConnectionMultiplexer multiplexer, ServerEndPoint server, o ...@@ -30,8 +30,8 @@ internal RedisServer(ConnectionMultiplexer multiplexer, ServerEndPoint server, o
public bool AllowSlaveWrites public bool AllowSlaveWrites
{ {
get => server.AllowSlaveWrites; get => server.AllowSlaveWrites;
set => server.AllowSlaveWrites = value; set => server.AllowSlaveWrites = value;
} }
public ServerType ServerType => server.ServerType; public ServerType ServerType => server.ServerType;
...@@ -61,7 +61,7 @@ public Task<long> ClientKillAsync(long? id = null, ClientType? clientType = null ...@@ -61,7 +61,7 @@ public Task<long> ClientKillAsync(long? id = null, ClientType? clientType = null
var msg = GetClientKillMessage(endpoint, id, clientType, skipMe, flags); var msg = GetClientKillMessage(endpoint, id, clientType, skipMe, flags);
return ExecuteAsync(msg, ResultProcessor.Int64); return ExecuteAsync(msg, ResultProcessor.Int64);
} }
private Message GetClientKillMessage(EndPoint endpoint, long? id, ClientType? clientType, bool skipMe, CommandFlags flags) private Message GetClientKillMessage(EndPoint endpoint, long? id, ClientType? clientType, bool skipMe, CommandFlags flags)
{ {
var parts = new List<RedisValue>(9) var parts = new List<RedisValue>(9)
...@@ -193,7 +193,7 @@ public Task ConfigSetAsync(RedisValue setting, RedisValue value, CommandFlags fl ...@@ -193,7 +193,7 @@ public Task ConfigSetAsync(RedisValue setting, RedisValue value, CommandFlags fl
ExecuteSync(Message.Create(-1, flags | CommandFlags.FireAndForget, RedisCommand.CONFIG, RedisLiterals.GET, setting), ResultProcessor.AutoConfigure); ExecuteSync(Message.Create(-1, flags | CommandFlags.FireAndForget, RedisCommand.CONFIG, RedisLiterals.GET, setting), ResultProcessor.AutoConfigure);
return task; return task;
} }
public long DatabaseSize(int database = 0, CommandFlags flags = CommandFlags.None) public long DatabaseSize(int database = 0, CommandFlags flags = CommandFlags.None)
{ {
var msg = Message.Create(database, flags, RedisCommand.DBSIZE); var msg = Message.Create(database, flags, RedisCommand.DBSIZE);
...@@ -211,7 +211,7 @@ public RedisValue Echo(RedisValue message, CommandFlags flags) ...@@ -211,7 +211,7 @@ public RedisValue Echo(RedisValue message, CommandFlags flags)
var msg = Message.Create(-1, flags, RedisCommand.ECHO, message); var msg = Message.Create(-1, flags, RedisCommand.ECHO, message);
return ExecuteSync(msg, ResultProcessor.RedisValue); return ExecuteSync(msg, ResultProcessor.RedisValue);
} }
public Task<RedisValue> EchoAsync(RedisValue message, CommandFlags flags) public Task<RedisValue> EchoAsync(RedisValue message, CommandFlags flags)
{ {
var msg = Message.Create(-1, flags, RedisCommand.ECHO, message); var msg = Message.Create(-1, flags, RedisCommand.ECHO, message);
...@@ -223,7 +223,7 @@ public void FlushAllDatabases(CommandFlags flags = CommandFlags.None) ...@@ -223,7 +223,7 @@ public void FlushAllDatabases(CommandFlags flags = CommandFlags.None)
var msg = Message.Create(-1, flags, RedisCommand.FLUSHALL); var msg = Message.Create(-1, flags, RedisCommand.FLUSHALL);
ExecuteSync(msg, ResultProcessor.DemandOK); ExecuteSync(msg, ResultProcessor.DemandOK);
} }
public Task FlushAllDatabasesAsync(CommandFlags flags = CommandFlags.None) public Task FlushAllDatabasesAsync(CommandFlags flags = CommandFlags.None)
{ {
var msg = Message.Create(-1, flags, RedisCommand.FLUSHALL); var msg = Message.Create(-1, flags, RedisCommand.FLUSHALL);
...@@ -318,7 +318,7 @@ public void MakeMaster(ReplicationChangeOptions options, TextWriter log = null) ...@@ -318,7 +318,7 @@ public void MakeMaster(ReplicationChangeOptions options, TextWriter log = null)
{ {
multiplexer.MakeMaster(server, options, log); multiplexer.MakeMaster(server, options, log);
} }
public void Save(SaveType type, CommandFlags flags = CommandFlags.None) public void Save(SaveType type, CommandFlags flags = CommandFlags.None)
{ {
var msg = GetSaveMessage(type, flags); var msg = GetSaveMessage(type, flags);
...@@ -379,16 +379,16 @@ public Task<byte[]> ScriptLoadAsync(string script, CommandFlags flags = CommandF ...@@ -379,16 +379,16 @@ public Task<byte[]> ScriptLoadAsync(string script, CommandFlags flags = CommandF
{ {
var msg = new RedisDatabase.ScriptLoadMessage(flags, script); var msg = new RedisDatabase.ScriptLoadMessage(flags, script);
return ExecuteAsync(msg, ResultProcessor.ScriptLoad); return ExecuteAsync(msg, ResultProcessor.ScriptLoad);
} }
public LoadedLuaScript ScriptLoad(LuaScript script, CommandFlags flags = CommandFlags.None) public LoadedLuaScript ScriptLoad(LuaScript script, CommandFlags flags = CommandFlags.None)
{ {
return script.Load(this, flags); return script.Load(this, flags);
} }
public Task<LoadedLuaScript> ScriptLoadAsync(LuaScript script, CommandFlags flags = CommandFlags.None) public Task<LoadedLuaScript> ScriptLoadAsync(LuaScript script, CommandFlags flags = CommandFlags.None)
{ {
return script.LoadAsync(this, flags); return script.LoadAsync(this, flags);
} }
public void Shutdown(ShutdownMode shutdownMode = ShutdownMode.Default, CommandFlags flags = CommandFlags.None) public void Shutdown(ShutdownMode shutdownMode = ShutdownMode.Default, CommandFlags flags = CommandFlags.None)
...@@ -677,7 +677,7 @@ public static RedisValue Encode(byte[] value) ...@@ -677,7 +677,7 @@ public static RedisValue Encode(byte[] value)
} }
return result; return result;
} }
public static RedisValue Hash(string value) public static RedisValue Hash(string value)
{ {
if (value == null) return default(RedisValue); if (value == null) return default(RedisValue);
...@@ -724,7 +724,7 @@ protected override Message CreateMessage(long cursor) ...@@ -724,7 +724,7 @@ protected override Message CreateMessage(long cursor)
} }
} }
} }
protected override ResultProcessor<ScanResult> Processor => processor; protected override ResultProcessor<ScanResult> Processor => processor;
public static readonly ResultProcessor<ScanResult> processor = new KeysResultProcessor(); public static readonly ResultProcessor<ScanResult> processor = new KeysResultProcessor();
......
...@@ -107,7 +107,7 @@ internal override T ExecuteSync<T>(Message message, ResultProcessor<T> processor ...@@ -107,7 +107,7 @@ internal override T ExecuteSync<T>(Message message, ResultProcessor<T> processor
{ {
throw new NotSupportedException("ExecuteSync cannot be used inside a transaction"); throw new NotSupportedException("ExecuteSync cannot be used inside a transaction");
} }
private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> processor) private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> processor)
{ {
var work = pending; var work = pending;
...@@ -121,14 +121,14 @@ private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> proc ...@@ -121,14 +121,14 @@ private Message CreateMessage(CommandFlags flags, out ResultProcessor<bool> proc
{ {
processor = null; processor = null;
return null; // they won't notice if we don't do anything... return null; // they won't notice if we don't do anything...
} }
processor = ResultProcessor.DemandPONG; processor = ResultProcessor.DemandPONG;
return Message.Create(-1, flags, RedisCommand.PING); return Message.Create(-1, flags, RedisCommand.PING);
} }
processor = TransactionProcessor.Default; processor = TransactionProcessor.Default;
return new TransactionMessage(Database, flags, cond, work); return new TransactionMessage(Database, flags, cond, work);
} }
private class QueuedMessage : Message private class QueuedMessage : Message
{ {
public Message Wrapped { get; } public Message Wrapped { get; }
...@@ -142,13 +142,13 @@ public QueuedMessage(Message message) : base(message.Db, message.Flags | Command ...@@ -142,13 +142,13 @@ public QueuedMessage(Message message) : base(message.Db, message.Flags | Command
public bool WasQueued public bool WasQueued
{ {
get => wasQueued; get => wasQueued;
set => wasQueued = value; set => wasQueued = value;
} }
internal override void WriteImpl(PhysicalConnection physical) internal override void WriteImpl(PhysicalConnection physical)
{ {
Wrapped.WriteImpl(physical); Wrapped.WriteImpl(physical);
Wrapped.SetRequestSent(); Wrapped.SetRequestSent();
} }
} }
...@@ -161,16 +161,16 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes ...@@ -161,16 +161,16 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
{ {
if (result.Type == ResultType.SimpleString && result.IsEqual(QUEUED)) if (result.Type == ResultType.SimpleString && result.IsEqual(QUEUED))
{ {
if (message is QueuedMessage q) if (message is QueuedMessage q)
{ {
q.WasQueued = true; q.WasQueued = true;
} }
return true; return true;
} }
return false; return false;
} }
} }
private class TransactionMessage : Message, IMultiMessage private class TransactionMessage : Message, IMultiMessage
{ {
private static readonly ConditionResult[] NixConditions = new ConditionResult[0]; private static readonly ConditionResult[] NixConditions = new ConditionResult[0];
...@@ -193,7 +193,7 @@ public override void AppendStormLog(StringBuilder sb) ...@@ -193,7 +193,7 @@ public override void AppendStormLog(StringBuilder sb)
if (conditions.Length != 0) sb.Append(", ").Append(conditions.Length).Append(" conditions"); if (conditions.Length != 0) sb.Append(", ").Append(conditions.Length).Append(" conditions");
sb.Append(", ").Append(InnerOperations.Length).Append(" operations"); sb.Append(", ").Append(InnerOperations.Length).Append(" operations");
} }
public override int GetHashSlot(ServerSelectionStrategy serverSelectionStrategy) public override int GetHashSlot(ServerSelectionStrategy serverSelectionStrategy)
{ {
int slot = ServerSelectionStrategy.NoSlot; int slot = ServerSelectionStrategy.NoSlot;
...@@ -373,23 +373,23 @@ private bool AreAllConditionsSatisfied(ConnectionMultiplexer multiplexer) ...@@ -373,23 +373,23 @@ private bool AreAllConditionsSatisfied(ConnectionMultiplexer multiplexer)
private class TransactionProcessor : ResultProcessor<bool> private class TransactionProcessor : ResultProcessor<bool>
{ {
public static readonly TransactionProcessor Default = new TransactionProcessor(); public static readonly TransactionProcessor Default = new TransactionProcessor();
public override bool SetResult(PhysicalConnection connection, Message message, RawResult result) public override bool SetResult(PhysicalConnection connection, Message message, RawResult result)
{ {
if (result.IsError && message is TransactionMessage tran) if (result.IsError && message is TransactionMessage tran)
{ {
string error = result.GetString(); string error = result.GetString();
var bridge = connection.Bridge; var bridge = connection.Bridge;
foreach (var op in tran.InnerOperations) foreach (var op in tran.InnerOperations)
{ {
ServerFail(op.Wrapped, error); ServerFail(op.Wrapped, error);
bridge.CompleteSyncOrAsync(op.Wrapped); bridge.CompleteSyncOrAsync(op.Wrapped);
} }
} }
return base.SetResult(connection, message, result); return base.SetResult(connection, message, result);
} }
protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result) protected override bool SetResultCore(PhysicalConnection connection, Message message, RawResult result)
{ {
if (message is TransactionMessage tran) if (message is TransactionMessage tran)
......
...@@ -7,7 +7,7 @@ namespace StackExchange.Redis ...@@ -7,7 +7,7 @@ namespace StackExchange.Redis
{ {
internal abstract partial class ResultBox internal abstract partial class ResultBox
{ {
protected Exception exception; protected Exception exception;
public void SetException(Exception exception) public void SetException(Exception exception)
{ {
...@@ -32,16 +32,16 @@ protected static void IncrementAllocationCount() ...@@ -32,16 +32,16 @@ protected static void IncrementAllocationCount()
static partial void OnAllocated(); static partial void OnAllocated();
} }
internal sealed class ResultBox<T> : ResultBox internal sealed class ResultBox<T> : ResultBox
{ {
private static readonly ResultBox<T>[] store = new ResultBox<T>[64]; private static readonly ResultBox<T>[] store = new ResultBox<T>[64];
private object stateOrCompletionSource; private object stateOrCompletionSource;
private T value; private T value;
public ResultBox(object stateOrCompletionSource) public ResultBox(object stateOrCompletionSource)
{ {
this.stateOrCompletionSource = stateOrCompletionSource; this.stateOrCompletionSource = stateOrCompletionSource;
} }
public object AsyncState => public object AsyncState =>
...@@ -78,11 +78,11 @@ public static void UnwrapAndRecycle(ResultBox<T> box, bool recycle, out T value, ...@@ -78,11 +78,11 @@ public static void UnwrapAndRecycle(ResultBox<T> box, bool recycle, out T value,
exception = box.exception; exception = box.exception;
box.value = default(T); box.value = default(T);
box.exception = null; box.exception = null;
if (recycle) if (recycle)
{ {
for (int i = 0; i < store.Length; i++) for (int i = 0; i < store.Length; i++)
{ {
if (Interlocked.CompareExchange(ref store[i], box, null) == null) return; if (Interlocked.CompareExchange(ref store[i], box, null) == null) return;
} }
} }
} }
...@@ -96,17 +96,17 @@ public void SetResult(T value) ...@@ -96,17 +96,17 @@ public void SetResult(T value)
public override bool TryComplete(bool isAsync) public override bool TryComplete(bool isAsync)
{ {
if (stateOrCompletionSource is TaskCompletionSource<T> tcs) if (stateOrCompletionSource is TaskCompletionSource<T> tcs)
{ {
#if !PLAT_SAFE_CONTINUATIONS // we don't need to check in this scenario #if !PLAT_SAFE_CONTINUATIONS // we don't need to check in this scenario
if (isAsync || TaskSource.IsSyncSafe(tcs.Task)) if (isAsync || TaskSource.IsSyncSafe(tcs.Task))
#endif #endif
{ {
UnwrapAndRecycle(this, true, out T val, out Exception ex); UnwrapAndRecycle(this, true, out T val, out Exception ex);
if (ex == null) if (ex == null)
{ {
tcs.TrySetResult(val); tcs.TrySetResult(val);
} }
else else
{ {
if (ex is TaskCanceledException) tcs.TrySetCanceled(); if (ex is TaskCanceledException) tcs.TrySetCanceled();
...@@ -116,12 +116,12 @@ public override bool TryComplete(bool isAsync) ...@@ -116,12 +116,12 @@ public override bool TryComplete(bool isAsync)
GC.SuppressFinalize(tcs.Task); GC.SuppressFinalize(tcs.Task);
} }
return true; return true;
} }
#if !PLAT_SAFE_CONTINUATIONS #if !PLAT_SAFE_CONTINUATIONS
else else
{ // looks like continuations; push to async to preserve the reader thread { // looks like continuations; push to async to preserve the reader thread
return false; return false;
} }
#endif #endif
} }
else else
...@@ -138,7 +138,7 @@ public override bool TryComplete(bool isAsync) ...@@ -138,7 +138,7 @@ public override bool TryComplete(bool isAsync)
private void Reset(object stateOrCompletionSource) private void Reset(object stateOrCompletionSource)
{ {
value = default(T); value = default(T);
exception = null; exception = null;
this.stateOrCompletionSource = stateOrCompletionSource; this.stateOrCompletionSource = stateOrCompletionSource;
} }
......
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