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

Tweak libuv shutdown sequence #1735

Merged
merged 2 commits into from
Apr 21, 2017
Merged

Tweak libuv shutdown sequence #1735

merged 2 commits into from
Apr 21, 2017

Conversation

davidfowl
Copy link
Member

  • Increase timeouts for thread and listener shutdowns
  • Use PostAsync to observe ObjectDisposedExceptions in the shutdown sequence

- Increase timeouts for thread and listener shutdowns
- Use PostAsync to observe ObjectDisposedExceptions in the shutdown sequence
@@ -103,15 +102,15 @@ public Task StartAsync()
{
var stepTimeout = TimeSpan.FromTicks(timeout.Ticks / 3);

Post(t => t.AllowStop());
await PostAsync(t => t.AllowStop(), this).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

Won't this prevent StopAsync from completing if the event loop is deadlocked?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it will. I'll add a check in AllowStop itself. It's safer.

Copy link
Member

Choose a reason for hiding this comment

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

What's the benefit of PostAsync here if we are waiting for _threadTcs.Task to complete anyway?

@@ -123,7 +123,7 @@ await Task.WhenAll(Threads.Select(thread => thread.StopAsync(TimeSpan.FromSecond
{
var disposeTasks = _listeners.Select(listener => listener.DisposeAsync()).ToArray();

if (!await WaitAsync(Task.WhenAll(disposeTasks), TimeSpan.FromSeconds(2.5)).ConfigureAwait(false))
if (!await WaitAsync(Task.WhenAll(disposeTasks), TimeSpan.FromSeconds(5)).ConfigureAwait(false))
Copy link
Member

Choose a reason for hiding this comment

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

Did you see this being timed out?

Copy link
Member Author

Choose a reason for hiding this comment

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

@halter73
Copy link
Member

Use PostAsync to observe ObjectDisposedExceptions in the shutdown sequence

Do you have any evidence that the ODEs are coming from AllowStop, OnStopRude or OnStopImmediate?

@davidfowl
Copy link
Member Author

Spoke to @halter73 about this and decided to just remove the unreference from AllowStopRude

@davidfowl davidfowl merged commit feb9d12 into dev Apr 21, 2017
@davidfowl
Copy link
Member Author

{System.ObjectDisposedException: Safe handle has been closed
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.NativeMethods.uv_unref(UvHandle handle)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.unref(UvHandle handle)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvHandle.Unreference()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.OnStopRude()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.<>c.<StopAsync>b__39_1(LibuvThread t)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.CallbackAdapter`1.<>c.<.cctor>b__3_0(Object callback, Object state)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.DoPostWork()}

@davidfowl davidfowl deleted the davidfowl/test-reliability branch April 25, 2017 00:38
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.

3 participants