Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit e952c92

Browse files
committed
Use explicit flag to determine if command was written to buffer
1 parent 1c50d15 commit e952c92

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ protected T SendReceive<T>(byte[][] cmdWithBinaryArgs,
526526
}
527527

528528
var i = 0;
529+
var didWriteToBuffer = false;
529530
Exception originalEx = null;
530531

531532
var firstAttempt = DateTime.UtcNow;
@@ -539,8 +540,11 @@ protected T SendReceive<T>(byte[][] cmdWithBinaryArgs,
539540
if (socket == null)
540541
throw new RedisRetryableException("Socket is not connected");
541542

542-
if (i == 0) //only write to buffer once
543+
if (!didWriteToBuffer) //only write to buffer once
544+
{
543545
WriteCommandToSendBuffer(cmdWithBinaryArgs);
546+
didWriteToBuffer = true;
547+
}
544548

545549
if (Pipeline == null) //pipeline will handle flush if in pipeline
546550
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using ServiceStack.Logging;
5+
using ServiceStack.Redis;
6+
using ServiceStack.Text;
7+
8+
namespace ConsoleTests
9+
{
10+
public class BlockingRemoveAfterReconnection
11+
{
12+
protected internal static RedisManagerPool BasicRedisClientManager;
13+
14+
public void Execute()
15+
{
16+
//RedisConfig.AssumeServerVersion = 4000;
17+
RedisConfig.DefaultConnectTimeout = 20 * 1000;
18+
RedisConfig.DefaultRetryTimeout = 20 * 1000;
19+
BasicRedisClientManager = new RedisManagerPool();
20+
try
21+
{
22+
using (var client = BasicRedisClientManager.GetClient())
23+
{
24+
Console.WriteLine("Blocking...");
25+
var fromList = client.BlockingRemoveStartFromList("AnyQueue", TimeSpan.FromMinutes(20));
26+
Console.WriteLine($"Received: {fromList.Dump()}");
27+
}
28+
}
29+
catch (Exception e)
30+
{
31+
Console.WriteLine(e);
32+
}
33+
}
34+
}
35+
}

tests/Console.Tests/Console.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
</ItemGroup>
8282
<ItemGroup>
8383
<Compile Include="BlockingPop.cs" />
84+
<Compile Include="BlockingRemoveAfterReconnection.cs" />
8485
<Compile Include="BrPopAfterReconnection.cs" />
8586
<Compile Include="ForceFailover.cs" />
8687
<Compile Include="MasterFailoverWithPassword.cs" />

tests/Console.Tests/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void Main(string[] args)
3838

3939
//new MasterFailoverWithPassword().Execute();
4040

41-
new BrPopAfterReconnection().Execute();
41+
new BlockingRemoveAfterReconnection().Execute();
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)