Merge branch 'benaadams/listener-primary-alloc' into dev

This commit is contained in:
Stephen Halter 2015-11-04 10:14:52 -08:00
commit 35bbddf9b5
1 changed files with 15 additions and 8 deletions

View File

@ -19,6 +19,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{ {
private List<UvPipeHandle> _dispatchPipes = new List<UvPipeHandle>(); private List<UvPipeHandle> _dispatchPipes = new List<UvPipeHandle>();
private int _dispatchIndex; private int _dispatchIndex;
private string _pipeName;
// this message is passed to write2 because it must be non-zero-length, // this message is passed to write2 because it must be non-zero-length,
// but it has no other functional significance // but it has no other functional significance
@ -36,18 +37,24 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
KestrelThread thread, KestrelThread thread,
RequestDelegate application) RequestDelegate application)
{ {
_pipeName = pipeName;
await StartAsync(address, thread, application).ConfigureAwait(false); await StartAsync(address, thread, application).ConfigureAwait(false);
await Thread.PostAsync(_ => await Thread.PostAsync(_this => _this.PostCallback(),
{ this).ConfigureAwait(false);
ListenPipe = new UvPipeHandle(Log);
ListenPipe.Init(Thread.Loop, false);
ListenPipe.Bind(pipeName);
ListenPipe.Listen(Constants.ListenBacklog, OnListenPipe, null);
}, null).ConfigureAwait(false);
} }
private void OnListenPipe(UvStreamHandle pipe, int status, Exception error, object state) 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)
{ {
if (status < 0) if (status < 0)
{ {