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

Move shutdown logic from transport to core #1707

Merged
merged 9 commits into from
Apr 20, 2017
Merged

Move shutdown logic from transport to core #1707

merged 9 commits into from
Apr 20, 2017

Conversation

halter73
Copy link
Member

  • Use weak references to track FrameConnections which are equivalent to libuv references.

});

var allAbortedTask = Task.WhenAll(abortTasks.ToArray());
return await Task.WhenAny(allAbortedTask, Task.Delay(1000)).ConfigureAwait(false) == allAbortedTask;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding 1 second?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abort was previously hard coded to one second. This timeout comes after the shutdown timeout is exceed/token canceled. What would you change this to?

@@ -86,29 +83,13 @@ public LibuvConnection()
// Ensure the socket is disposed prior to completing in the input writer.
_socket.Dispose();
Input.Complete(new TaskCanceledException("The request was aborted"));
_socketClosedTcs.TrySetResult(null);
_connectionContext.OnConnectionClosed();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code makes it look like there's a chance that OnConnection can throw and as a result OnConnectionClosed won't be called.

Copy link
Member Author

@halter73 halter73 Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you're getting at. What looks like it can throw?

@@ -165,7 +165,7 @@ public static IEnumerable<object[]> LargeUploadData

using (var reader = new StreamReader(stream, Encoding.ASCII))
{
var response = reader.ReadToEnd();
var response = await reader.ReadToEndAsync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be synchronous for the timeout to work.

public async Task CriticalErrorLoggedIfApplicationDoesntComplete()
{
////////////////////////////////////////////////////////////////////////////////////////
// WARNING: This test will fail under a debugger because Task.s_currentActiveTasks //
Copy link
Member

@davidfowl davidfowl Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞. Should we let this test pass if Debugger.IsAttached?

@@ -27,8 +27,6 @@ protected UvStreamHandle(ILibuvTrace logger) : base(logger)
{
}

public LibuvConnection Connection { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

{
private readonly ConcurrentDictionary<long, FrameConnection> _connections
= new ConcurrentDictionary<long, FrameConnection>();
// Internal for testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo internal

public async Task CriticalErrorLoggedIfApplicationDoesntComplete()
{
////////////////////////////////////////////////////////////////////////////////////////
// WARNING: This test will fail under a debugger because Task.s_currentActiveTasks //
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use custom awaiter?

@halter73 halter73 force-pushed the halter73/1585 branch 3 times, most recently from 0155a10 to 3ffe334 Compare April 19, 2017 00:13
@davidfowl
Copy link
Member

davidfowl commented Apr 19, 2017

[xUnit.net 00:00:17.8537490]     ResponseStatusCodeSetBeforeHttpContextDisposeAppException [FAIL]
[xUnit.net 00:00:17.8561410]       System.AggregateException : One or more errors occurred. (Error -16 EBUSY resource busy or locked)
[xUnit.net 00:00:17.8562890]       ---- Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException : Error -16 EBUSY resource busy or locked
[xUnit.net 00:00:17.8579300]       Stack Trace:
[xUnit.net 00:00:17.8597300]            at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[xUnit.net 00:00:17.8598640]            at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
[xUnit.net 00:00:17.8599380]            at System.Threading.Tasks.Task.Wait()
[xUnit.net 00:00:17.8599880]            at Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.TestServer.Dispose()
[xUnit.net 00:00:17.8600400]            at Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.ResponseTests.<ResponseStatusCodeSetBeforeHttpContextDispose>d__12.MoveNext()
[xUnit.net 00:00:17.8600720]         --- End of stack trace from previous location where exception was thrown ---
[xUnit.net 00:00:17.8601330]            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[xUnit.net 00:00:17.8601860]            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[xUnit.net 00:00:17.8602230]         --- End of stack trace from previous location where exception was thrown ---
[xUnit.net 00:00:17.8602710]            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[xUnit.net 00:00:17.8603230]            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[xUnit.net 00:00:17.8603580]         --- End of stack trace from previous location where exception was thrown ---
[xUnit.net 00:00:17.8603970]            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[xUnit.net 00:00:17.8604600]            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[xUnit.net 00:00:17.8605480]         ----- Inner Stack Trace -----
[xUnit.net 00:00:17.8606310]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.ThrowError(Int32 statusCode)
[xUnit.net 00:00:17.8606890]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.ThrowIfErrored(Int32 statusCode)
[xUnit.net 00:00:17.8607420]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.loop_close(UvLoopHandle handle)
[xUnit.net 00:00:17.8607900]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvLoopHandle.ReleaseHandle()
[xUnit.net 00:00:17.8608330]            at System.Runtime.InteropServices.SafeHandle.InternalDispose()
[xUnit.net 00:00:17.8608780]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.ThreadStart(Object parameter)
[xUnit.net 00:00:17.8609120]         --- End of stack trace from previous location where exception was thrown ---
[xUnit.net 00:00:17.8609680]            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[xUnit.net 00:00:17.8610180]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.<StopAsync>d__37.MoveNext()
[xUnit.net 00:00:17.8610580]         --- End of stack trace from previous location where exception was thrown ---
[xUnit.net 00:00:17.8611220]            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[xUnit.net 00:00:17.8611680]            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[xUnit.net 00:00:17.8612160]            at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.LibuvTransport.<StopAsync>d__19.MoveNext()
[xUnit.net 00:00:17.9084150]   Finished:    Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
Failed   ResponseStatusCodeSetBeforeHttpContextDisposeAppException
Error Message:
 System.AggregateException : One or more errors occurred. (Error -16 EBUSY resource busy or locked)
---- Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException : Error -16 EBUSY resource busy or locked
Stack Trace:

@halter73 halter73 force-pushed the halter73/1585 branch 4 times, most recently from d10a05a to ec72961 Compare April 19, 2017 23:46
@@ -24,6 +24,7 @@ public class LoggingConnectionAdapterTests
{
listenOptions.UseConnectionLogging();
listenOptions.UseHttps(TestResources.TestCertificatePath, "testPassword");
listenOptions.UseConnectionLogging();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants