Set IsBackground property to true on libuv Threads for non-debug builds
- If libuv doesn't shutdown as expected, the process will still stop. Thanks @benaadams! - Address other minor PR feedback.
This commit is contained in:
parent
04736e1d09
commit
bc56d11d8c
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
|||
{
|
||||
if (_connectionStopTasks != null)
|
||||
{
|
||||
throw new InvalidOperationException(nameof(WalkConnectionsAndClose) + " cannot be called twice.");
|
||||
throw new InvalidOperationException($"{nameof(WalkConnectionsAndClose)} cannot be called twice.");
|
||||
}
|
||||
|
||||
_connectionStopTasks = new List<Task>();
|
||||
|
|
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
|||
{
|
||||
if (_connectionStopTasks == null)
|
||||
{
|
||||
throw new InvalidOperationException(nameof(WalkConnectionsAndClose) + " must be called first.");
|
||||
throw new InvalidOperationException($"{nameof(WalkConnectionsAndClose)} must be called first.");
|
||||
}
|
||||
|
||||
return Task.WhenAll(_connectionStopTasks);
|
||||
|
|
|
|||
|
|
@ -189,12 +189,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
|||
|
||||
protected FrameRequestHeaders FrameRequestHeaders => _frameHeaders.RequestHeaders;
|
||||
|
||||
public Frame InitializeHeaders()
|
||||
public void InitializeHeaders()
|
||||
{
|
||||
_frameHeaders = HttpComponentFactory.CreateHeaders(DateHeaderValueManager);
|
||||
RequestHeaders = _frameHeaders.RequestHeaders;
|
||||
ResponseHeaders = _frameHeaders.ResponseHeaders;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel
|
|||
|
||||
public void Stop(TimeSpan timeout)
|
||||
{
|
||||
#if !DEBUG
|
||||
// Mark the thread as being as unimportant to keeping the process alive.
|
||||
// Don't do this for debug builds, so we know if the thread isn't terminating.
|
||||
_thread.IsBackground = true;
|
||||
#endif
|
||||
|
||||
if (!_initCompleted)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
ServerInformation = serverInformation,
|
||||
HttpComponentFactory = new HttpComponentFactory(serverInformation)
|
||||
};
|
||||
var frame = new Frame<object>(application: null, context: connectionContext)
|
||||
.InitializeHeaders();
|
||||
var frame = new Frame<object>(application: null, context: connectionContext);
|
||||
frame.InitializeHeaders();
|
||||
|
||||
IDictionary<string, StringValues> headers = frame.ResponseHeaders;
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
ServerInformation = serverInformation,
|
||||
HttpComponentFactory = new HttpComponentFactory(serverInformation)
|
||||
};
|
||||
var frame = new Frame<object>(application: null, context: connectionContext)
|
||||
.InitializeHeaders();
|
||||
var frame = new Frame<object>(application: null, context: connectionContext);
|
||||
frame.InitializeHeaders();
|
||||
|
||||
Assert.True(frame.ResponseHeaders.Count > 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Server.Kestrel;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Networking;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue