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