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

Commit c00f679

Browse files
author
Pete Ness
committed
Fix waitForWriter to actually wait (and not throw).
1 parent dbc2e46 commit c00f679

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/ServiceStack.Redis/PooledRedisClientManager.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,14 @@ protected virtual void OnStart()
216216
{
217217
this.Start();
218218
}
219-
219+
220220
private async Task<bool> waitForWriter(int msTimeout)
221221
{
222-
writeMonitor = new AsyncMonitor();
223-
var cts = new CancellationTokenSource();
224-
cts.CancelAfter(msTimeout);
225-
await writeMonitor.WaitAsync(cts.Token);
226-
if (cts.IsCancellationRequested) return false;
227-
cts.Cancel();
222+
if (writeMonitor == null)
223+
writeMonitor = new AsyncMonitor();
224+
var delayTask = Task.Delay(msTimeout);
225+
var result = await Task.WhenAny(writeMonitor.WaitAsync(), delayTask);
226+
if (result == delayTask) return false;
228227
return true;
229228
}
230229

0 commit comments

Comments
 (0)