Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ abstract public class ListenerPrimary : Listener
{
private List<UvPipeHandle> _dispatchPipes = new List<UvPipeHandle>();
private int _dispatchIndex;
private string _pipeName;

// this message is passed to write2 because it must be non-zero-length,
// but it has no other functional significance
Expand All @@ -36,18 +37,24 @@ public async Task StartAsync(
KestrelThread thread,
RequestDelegate application)
{
_pipeName = pipeName;

await StartAsync(address, thread, application).ConfigureAwait(false);

await Thread.PostAsync(_ =>
{
ListenPipe = new UvPipeHandle(Log);
ListenPipe.Init(Thread.Loop, false);
ListenPipe.Bind(pipeName);
ListenPipe.Listen(Constants.ListenBacklog, OnListenPipe, null);
}, null).ConfigureAwait(false);
await Thread.PostAsync(_this => _this.PostCallback(),
this).ConfigureAwait(false);
}

private void PostCallback()
{
ListenPipe = new UvPipeHandle(Log);
ListenPipe.Init(Thread.Loop, false);
ListenPipe.Bind(_pipeName);
ListenPipe.Listen(Constants.ListenBacklog,
(pipe, status, error, state) => ((ListenerPrimary)state).OnListenPipe(pipe, status, error), this);
}

private void OnListenPipe(UvStreamHandle pipe, int status, Exception error, object state)
private void OnListenPipe(UvStreamHandle pipe, int status, Exception error)
{
if (status < 0)
{
Expand Down