Fixed broken tests that leak UvWriteReq

This commit is contained in:
David Fowler 2017-04-19 17:50:24 -07:00
parent 7a3a731686
commit d40dbb81ea
1 changed files with 9 additions and 8 deletions

View File

@ -119,9 +119,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
// Wait for all writes to complete so the completeQueue isn't modified during enumeration. // Wait for all writes to complete so the completeQueue isn't modified during enumeration.
await _mockLibuv.OnPostTask; await _mockLibuv.OnPostTask;
foreach (var triggerCompleted in completeQueue) // Drain the write queue
while (completeQueue.TryDequeue(out var triggerNextCompleted))
{ {
await _libuvThread.PostAsync(cb => cb(0), triggerCompleted); await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
} }
} }
} }
@ -174,9 +175,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
// Wait for all writes to complete so the completeQueue isn't modified during enumeration. // Wait for all writes to complete so the completeQueue isn't modified during enumeration.
await _mockLibuv.OnPostTask; await _mockLibuv.OnPostTask;
foreach (var triggerCompleted in completeQueue) // Drain the write queue
while (completeQueue.TryDequeue(out triggerNextCompleted))
{ {
await _libuvThread.PostAsync(cb => cb(0), triggerCompleted); await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
} }
} }
} }
@ -234,9 +236,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
// Wait for all writes to complete so the completeQueue isn't modified during enumeration. // Wait for all writes to complete so the completeQueue isn't modified during enumeration.
await _mockLibuv.OnPostTask; await _mockLibuv.OnPostTask;
foreach (var triggerCompleted in completeQueue) // Drain the write queue
while (completeQueue.TryDequeue(out triggerNextCompleted))
{ {
await _libuvThread.PostAsync(cb => cb(0), triggerCompleted); await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
} }
} }
} }
@ -494,8 +497,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
} }
} }
private OutputProducer CreateOutputProducer(PipeOptions pipeOptions, CancellationTokenSource cts = null) private OutputProducer CreateOutputProducer(PipeOptions pipeOptions, CancellationTokenSource cts = null)
{ {
var pipe = _pipeFactory.Create(pipeOptions); var pipe = _pipeFactory.Create(pipeOptions);