From d40dbb81eabb907d624da5c3040056aca9693d51 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Wed, 19 Apr 2017 17:50:24 -0700 Subject: [PATCH] Fixed broken tests that leak UvWriteReq --- .../LibuvOutputConsumerTests.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs index 8bfaa8ba48..15cfc81453 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/LibuvOutputConsumerTests.cs @@ -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. 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. 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. 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) { var pipe = _pipeFactory.Create(pipeOptions);